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

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Lakelands01

Board Regular
Joined
Jul 14, 2005
Messages
56
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,546
Messages
5,838,029
Members
430,526
Latest member
NiceGuyWithExcel2007

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
Top