Select a row with a specific value in a given range

mkingrey

New Member
Joined
Nov 2, 2005
Messages
49
In row 1 of my worksheet I have a list of headers that contain dates. I need to write vba code that will select the cell(header) with a specific value in it.

Example,

if myVariable="11/28/2005" then I want to select the cell(header) with a value of 11/28/2005.

Logically I planned on using the MATCH worksheet function and then the ADDRESS worksheet function to return the cell address and then set the selection to the resulting address: Range(returnedaddress).Select

.....but this didn't work because the ADDRESS worksheet can't be used in VBA.

Can anyone help b/c I'm stumped?...thanks...
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
If I understand this problem correctly, this code may help:

Private Sub FindMatch()
Dim MyVariable As Date
MyVariable = Range("a4").Value

Range("a1").Activate
While ActiveCell.Value <> ""
If ActiveCell.Value <> MyVariable Then
ActiveCell.Offset(0, 1).Activate
Else
MsgBox "Found Match at Cell: " & ActiveCell.Address
Exit Sub
End If
Wend
Range("a1").Activate
MsgBox "No Match Found"

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,016
Messages
6,122,700
Members
449,092
Latest member
snoom82

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