DebtAcquisitions
New Member
- Joined
- May 20, 2015
- Messages
- 21
Hello Everyone, thanks for taking a look at my question.
I need to create a macro that will "check" if a file contains certain heater information.
Row 1 (sheet: File) contains header info example: FirstName, LastName, PhoneNumber.....
however, sometimes these are in the wrong order or are missing completey.
I have another sheet (Data) that contains possible data in a column.
Example for first name (column B) the header can contain:
Firstname, FName, F Name, and so on....
for now, I just want a msgbox to tell me something was found, I will add the correct code after I figure this out.
Below is a sample of the code I have created so far...
Sub NameTest()
' This is a working version as long as you identify exactly what to look for.
Dim myCol As Long, rngFound As Range
'Fname = "1"
Fname = Workbooks("IntChk.xlsm").Worksheets("Data").Range("B3")
'Fname = Workbooks("IntChk.xlsm").Worksheets("Data").Range("B:B")
Set rngFound = Worksheets("File").Rows(1).Find(What:=Fname, LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False)
If Not rngFound Is Nothing Then
myCol = rngFound.Column
MsgBox myCol
Else
MsgBox "Not Found"
End If
End Sub
I need to create a macro that will "check" if a file contains certain heater information.
Row 1 (sheet: File) contains header info example: FirstName, LastName, PhoneNumber.....
however, sometimes these are in the wrong order or are missing completey.
I have another sheet (Data) that contains possible data in a column.
Example for first name (column B) the header can contain:
Firstname, FName, F Name, and so on....
for now, I just want a msgbox to tell me something was found, I will add the correct code after I figure this out.
Below is a sample of the code I have created so far...
Sub NameTest()
' This is a working version as long as you identify exactly what to look for.
Dim myCol As Long, rngFound As Range
'Fname = "1"
Fname = Workbooks("IntChk.xlsm").Worksheets("Data").Range("B3")
'Fname = Workbooks("IntChk.xlsm").Worksheets("Data").Range("B:B")
Set rngFound = Worksheets("File").Rows(1).Find(What:=Fname, LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False)
If Not rngFound Is Nothing Then
myCol = rngFound.Column
MsgBox myCol
Else
MsgBox "Not Found"
End If
End Sub