FryGirl
Well-known Member
- Joined
- Nov 11, 2008
- Messages
- 1,366
- Office Version
- 365
- 2016
- Platform
- Windows
Not sure how to get the right syntax here to represent a variable number of sheets.
The 4 in the formula is the variable part. Whatever number is in Sheets("CtrlPnl").Range("H12") is the total number of sheets. In this example I've just shown 4, but it could be up to 20 or more.
Code:
Sub TryThis1()
Range("G2").Formula = "=AVERAGE('1:4'!E2)"
End Sub
The 4 in the formula is the variable part. Whatever number is in Sheets("CtrlPnl").Range("H12") is the total number of sheets. In this example I've just shown 4, but it could be up to 20 or more.