[ad_1]
I have a search that Identifies a range address with a specific header that works.
The function I am working on needs to search in the same row for another header string and return the cell address.
For some reason the find function does not populate the range variable with the address of the header in the file.
I have tried adjusting parameters in the find function but I am not having any luck figuring this out.
Thanks in advance for your help!
MsgBox "Finding all headers in the selected row"
'search left in the given row to find other header to copy data from under
Dim HeaderColFoundRng As Range
Dim dataWB As Workbook
Set dataWB = Workbooks.Open(dataFile)
Set HeaderColFoundRng = dataWB.Sheets("Sheet1").Range(rng).Find(What:=headerName, LookIn:=xlValues, _
LookAt:=xlWhole, SearchDirection:=xlPrevious) 'or xlNext
'needs to set each value address to a range that will be sent out
MsgBox HeaderColFoundRng.Address '<<< repeated variable not set error!
End Sub
Sub testSub2()
Dim FileToOpen As String
FileToOpen = Application.GetOpenFilename(Title:="Select Data file")
Call FindAllHeadersInRow(FileToOpen, "A68:AZ68", "Transaction Date") 'Header needed is located in T68
End Sub
[ad_2]