Hi!
This is the code that supposed to find the column with given value:
This function works perfect when i use it in spreadsheet but prompt the error above when i use it in VBA.
I searched for solution in google but all i found did not help me.
Please, what I am doing wrong?
This is the code that supposed to find the column with given value:
Code:
Sub main()
Dim s As Range
Set s = FindValueInCellRange(ThisWorkbook.Sheets(1).Range("A4:DO4"), "01/12/2022")
End Sub
Function FindValueInCellRange(MyRange As Range, MyValue As Variant) As Range
With MyRange
FindValueInCellRange = .Find(What:=MyValue, After:=.Cells(.Cells.Count), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext).Address(RowAbsolute:=False, ColumnAbsolute:=False)
End With
End Function
This function works perfect when i use it in spreadsheet but prompt the error above when i use it in VBA.
I searched for solution in google but all i found did not help me.
Please, what I am doing wrong?