I have a row of dates and I need to be able to search it for a value and when that value is encountered, I need to get the cell in which the value was found. Can someone help? Thanks, Jeremy
Printable View
I have a row of dates and I need to be able to search it for a value and when that value is encountered, I need to get the cell in which the value was found. Can someone help? Thanks, Jeremy
One way is to have a text box that you enter the date you're searching for and then use something like...
Code:Dim CurrentRow As Interger
oXLApp.Worksheets("Sheet1").Select
objExcel.Range("A1").Select
Do Until objExcel.ActiveCell.Value = Text1
objExcel.ActiveCell.Offset(1, 0).Select
Loop
CurrentRow = objExcel.ActiveCell.Row
How about a loop....
VB Code:
For i = 1 To 100 'Or whatever... If InStr(1, Range("$A$" & i).Value, Date) Then Range("$A$" & i).Select Exit For End If Next
Just a thought, untested code btw....:D
Public Sub datefind()
Dim sCell As Range
For Each sCell In Selection
If IsDate(sCell.Value) Then MsgBox (sCell.Value) ' STORE IN ARRAY OR PLACE ON SPREAD
Next
End Sub