I am currently learning to condense code by turning several macros that are similar into one that I can use for all.
The below is the last bit that I need to change to have a single macro instead of 7.
At this point, I am copying the ActiveSheet and a sheet called "Invoice" to a new workbook, then adding the formula to the sheet called "Invoice":
Sub InvComps()
Sheets(Array("Invoice", ActiveSheet.Name)).Copy
Range("J22").FormulaR1C1 = "=SUM(Complete!C[17])"
End Sub
Sub InvAborts()
Sheets(Array("Invoice", ActiveSheet.Name)).Copy
Range("J22").FormulaR1C1 = "=SUM(Aborts!C[17])"
End Sub
Sub InvEmergs()
Sheets(Array("Invoice", ActiveSheet.Name)).Copy
Range("J22").FormulaR1C1 = "=SUM(Emergencies!C[17])"
End Sub
Sub InvADV()
Sheets(Array("Invoice", ActiveSheet.Name)).Copy
Range("J22").FormulaR1C1 = "=SUM(ADV!C[17])"
End Sub
Sub InvSSE()
Sheets(Array("Invoice", ActiveSheet.Name)).Copy
Range("J22").FormulaR1C1 = "=SUM(SSE!C[17])"
End Sub
Sub InvUKMA()
Sheets(Array("Invoice", ActiveSheet.Name)).Copy
Range("J22").FormulaR1C1 = "=SUM(UKMA!C[17])"
End Sub
Sub InvUKGC()
Sheets(Array("Invoice", ActiveSheet.Name)).Copy
Range("J22").FormulaR1C1 = "=SUM(UKGC!C[17])"
End Sub
How do I get the sheet name in each formula to change each time so that it refers to the sheet in the workbook that isn't "Invoice"?
Thanks in advance.
Bookmarks