I am new at vba.
I need to locate the row number of certain employees in every workbooks
Employee names are sorted differently and are in another column for some workbooks.
Workbook names are located in column AC populated using dir().
From the code below, you will notice that $AC14 is static.
I want to replace $AC14 with something like "AC" & x + 14.
However, I am at a lost on how to accomplish this.
Any suggestion will be highly appreciated.
' $B$7 = employee name from drop down list
' $AA$7 = sheet name from drop down list
Private Sub GetEmployeeRow()
x = 0
Do While Range("AC" & x + 14).Value <> ""
If Left(Range("AC" & x + 14), 1) = "2" Then
Range("AA" & x + 14).Formula = "=MATCH($B$7,INDIRECT(""'[""&$AC14&""]""&$AA$7&""'!B:B""),0)"
End If
If Left(Range("AC" & x + 14), 1) = "C" Then
Range("AA" & x + 14).Formula = "=MATCH($B$7,INDIRECT(""'[""&$AC14&""]""&$AA$7&""'!C:C""),0)"
End If
' criteria for other workbooks
x = x + 1
Loop
End Sub
Thank you in advance.
I need to locate the row number of certain employees in every workbooks
Employee names are sorted differently and are in another column for some workbooks.
Workbook names are located in column AC populated using dir().
From the code below, you will notice that $AC14 is static.
I want to replace $AC14 with something like "AC" & x + 14.
However, I am at a lost on how to accomplish this.
Any suggestion will be highly appreciated.
' $B$7 = employee name from drop down list
' $AA$7 = sheet name from drop down list
Private Sub GetEmployeeRow()
x = 0
Do While Range("AC" & x + 14).Value <> ""
If Left(Range("AC" & x + 14), 1) = "2" Then
Range("AA" & x + 14).Formula = "=MATCH($B$7,INDIRECT(""'[""&$AC14&""]""&$AA$7&""'!B:B""),0)"
End If
If Left(Range("AC" & x + 14), 1) = "C" Then
Range("AA" & x + 14).Formula = "=MATCH($B$7,INDIRECT(""'[""&$AC14&""]""&$AA$7&""'!C:C""),0)"
End If
' criteria for other workbooks
x = x + 1
Loop
End Sub
Thank you in advance.