find a date created by a formula

gtd526

Well-known Member
Joined
Jul 30, 2013
Messages
690
Office Version
  1. 2019
Platform
  1. Windows
Hello,
I'm using the following code but it can't find the date because its created by a formula (EOMONTH). If the date is entered manually, its selected.
How can we make it find a date created by a formula?

VBA Code:
Set foundRng = Range("A:A").Find(DateSerial(Year(Date), Month(Date) + 1, 0))  'last day of current month
'find expenses
    If Not (foundRng Is Nothing) Then
        foundRng.Select
        ActiveCell.Offset(0, 21).Select
        Selection.Copy
        ActiveCell.PasteSpecial xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    Else
    End If

Thank you
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Try...
Rich (BB code):
Set foundRng = Range("A:A").Find(DateSerial(Year(Date), Month(Date) + 1, 0), , xlValues, xlWhole, , xlNext, False)
 
Upvote 0
Solution
You're welcome

Just an observation,
When you do a "Find" the parameters when you run the code are set by what your "Find" settings are in the Find window that appears when you do a Find manually.

About half the parameters retain a memory from when you last done a "Find" either manually or by code and so there is no default setting for all parameters.

Because of the above it very rare that you don't need to specifically define the parameters that are needed based on the specific data you are looking for and the layout when you start a new "find" (in your case the "LookIn" parameter being set as xlValues is essential), and so any code that only has the "What" parameter set is asking for issues to arise IMHO.

 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,319
Members
452,905
Latest member
deadwings

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top