Hi All,
Kind of new to VBA, and have been studying previous posts
I have 100s of worksheets with different ranges, but all need the same formulas applied to column A and B (if blank, preferably so that i can add and update the worksheets later).
I can only get A2 to populate, any chance someone can assist.
Many thanks
Sub Formula()
Dim lastRow As Long
Dim rs As Worksheet
lastRow = Range("A" & Rows.Count).End(xlUp).Row
For Each rs In ThisWorkbook.Worksheets
Range("A2").Formula = "=VLOOKUP(B2,'D:\test\[test.xlsx]sheet1'!$AG:$AG,1,FALSE)"
Range("B2").Formula ="=C2&":"&D2"
End
Next rs
End Sub
Kind of new to VBA, and have been studying previous posts
I have 100s of worksheets with different ranges, but all need the same formulas applied to column A and B (if blank, preferably so that i can add and update the worksheets later).
I can only get A2 to populate, any chance someone can assist.
Many thanks
Sub Formula()
Dim lastRow As Long
Dim rs As Worksheet
lastRow = Range("A" & Rows.Count).End(xlUp).Row
For Each rs In ThisWorkbook.Worksheets
Range("A2").Formula = "=VLOOKUP(B2,'D:\test\[test.xlsx]sheet1'!$AG:$AG,1,FALSE)"
Range("B2").Formula ="=C2&":"&D2"
End
Next rs
End Sub