Hello T De Villiers,
Add a Standard VBA module to your workbook and then copy and paste the maco code into it. See the example below for calling the macro in your code.
Sub SummaryMacro(Worksheet_Name As String)
Set wss = Worksheets(Worksheet_Name)
wss.Select
target = Worksheet_Name
Cells.Find(What:="itebal", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
itebalcol = ActiveCell.Column
If Left(sr.Cells(i, 1), 3) = target Then
Select Case sr.Cells(i, 1).Offset(0, 25)
Case Is = "GBP", "EUR", "USD", "RUB"
sr.Cells(i, 6) = WorksheetFunction.VLookup(sr.Cells(i, 1), wss.Range("A1:Z10000"), itebalcol, 0)
Case Else
sr.Cells(i, 10) = WorksheetFunction.VLookup(sr.Cells(i, 1), wss.Range("A1:Z10000"), itebalcol, 0)
End Select
End If
End Sub
Calling the Macro:
Your code now looks like this....
SummaryMacro "abn"
SummaryMacro "cap"
...etc
Sincerely,
Leith Ross
Bookmarks