VBA code for go to cell with a found value

Petula22

New Member
Joined
Mar 22, 2018
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to create a VBA code to find a value in a column based on a cell with formula TODAY and then use the application.go to.

Can you please help? Thank you.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Welcome to the Board!

Won't Excel's built-in FIND functionality do what you want?
If you want it in VBA code, simply turn on the Macro Recorder and record yourself using it, and you will get most of the VBA code you need to do this.
Then it should simply be a matter of replacing the hard-coded lookup value you used in the example with a variable set to the current date.

If you run into any problems with that, then let us know.
 
Upvote 0
Welcome to the Board!

Won't Excel's built-in FIND functionality do what you want?
If you want it in VBA code, simply turn on the Macro Recorder and record yourself using it, and you will get most of the VBA code you need to do this.
Then it should simply be a matter of replacing the hard-coded lookup value you used in the example with a variable set to the current date.

If you run into any problems with that, then let us know.

...
Thank you, Joe4. I tried that but it did not work with a cell value only with text or number. I tried it with text and it gave me this code:

"Cells.Find(What:="text", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate"

I have a cell with a formula =today() and I need the code to find the value of the formula in the column and then go to it. If that makes sense.
 
Upvote 0
What exactly do these entries that you are looking in look like?
Are they date or text entries?
 
Upvote 0
If the entries you are looking in just contains dates (formatted as dates), with no time or any other text, this macro would find the current date:
Code:
Sub MyFind()

    Dim findDate As Date
    findDate = Date

    Cells.Find(What:=findDate, After:=Range("A1"), LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate
        
End Sub
 
Upvote 0
Here is a version with error handling, in case it cannot find the date being searched for:
Code:
Sub MyFind()

    Dim findDate As Date
    findDate = Date

    On Error GoTo err_chk
    Cells.Find(What:=findDate, After:=Range("A1"), LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate
    On Error GoTo 0
    
    Exit Sub
    
err_chk:
    If Err.Number = 91 Then
        MsgBox "Cannot find date", vbOKOnly, "ERROR!"
    Else
        MsgBox Err.Number & ":" & Err.Description
    End If
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,807
Messages
6,121,679
Members
449,047
Latest member
notmrdurden

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