I have a workbook with multiple worksheets. I need VBA to insert formulas based on the worksheet name.
For example: a formula that will reference a value on another sheet in the workbook.
The sheet names are assigned dynamically with a 6-digit account numbers added to the existing sheet names earlier in the macro.
I tried using Application.Caller, but received an error message.
For example: a formula that will reference a value on another sheet in the workbook.
The sheet names are assigned dynamically with a 6-digit account numbers added to the existing sheet names earlier in the macro.
I tried using Application.Caller, but received an error message.
Code:
If Wkb.Sheets(Sheets.Count).Name Like "*Supplies" ThenRange("G45").Value = "=SUM(G9:H43)"
ElseIf Sheets(Sheets.Count).Name Like "*Travel" Then
Range("B7:B14").Columns.AutoFit
' Range("B15").Value = "='" & Application.Caller.Worksheet.Name & "'!H37"
End If
Last edited: