Hi,
I am new to VBA and struggling with a piece of code; any help would be much appreciated!
I am attempting to write some code which instructs the selection of a cell, within a range, whereby the cell to select is one row lower than the column header (row 1 of the column), if the column header matches a date in a fixed cell of another sheet (in the code attempt below, the fixed cell, which contains the date, is cell N1 in "Sheet1").
My attempt:
Sub test()
Dim Found As Range, LookFor As String
LookFor = Sheets("Sheet1").Range("N1").Value
Set Found = Sheets("Sheet1").Range("A1:H1").Find(what:=LookFor)
If Found Is Nothing Then
MsgBox "Not found"
Else
Range(Found.Offset(1, 0)).Select
End If
End Sub
Thanks in advance.
I am new to VBA and struggling with a piece of code; any help would be much appreciated!
I am attempting to write some code which instructs the selection of a cell, within a range, whereby the cell to select is one row lower than the column header (row 1 of the column), if the column header matches a date in a fixed cell of another sheet (in the code attempt below, the fixed cell, which contains the date, is cell N1 in "Sheet1").
My attempt:
Sub test()
Dim Found As Range, LookFor As String
LookFor = Sheets("Sheet1").Range("N1").Value
Set Found = Sheets("Sheet1").Range("A1:H1").Find(what:=LookFor)
If Found Is Nothing Then
MsgBox "Not found"
Else
Range(Found.Offset(1, 0)).Select
End If
End Sub
Thanks in advance.