craigexcel
Active Member
- Joined
- Jun 28, 2006
- Messages
- 298
- Office Version
- 2016
- Platform
- Windows
I'm using Office 365 Excel, with Windows 7 Enterprise.
I have multiple workbooks, that all have 12 monthly worksheets, plus several other sheets. I want to make certain updates in a given workbook, based on the value entered in the InputBox -- 1 for the "DEC18" sheet only, and, 2 for all 12 monthly sheets. (If there's a better way to do this, or any other part of the code for that matter, I'd appreciate your input!)
As I'm processing data in the December workbooks, I want to enter either a 1 or a 2 in the InputBox, and then for the code to either update only the "DEC18" worksheet, or, update all the monthly sheets, while ignoring any sheets that are not the 'monthly' sheets. The same code (which works for a single sheet as it is written now) needs to be run, but only for the sheet(s) 'identified' by having entered either a 1 or 2.
I can't wrap my head around what combo of For Each, Do ___, If, etc. would work best to do this.
So far, I have written this snippet:
I have multiple workbooks, that all have 12 monthly worksheets, plus several other sheets. I want to make certain updates in a given workbook, based on the value entered in the InputBox -- 1 for the "DEC18" sheet only, and, 2 for all 12 monthly sheets. (If there's a better way to do this, or any other part of the code for that matter, I'd appreciate your input!)
As I'm processing data in the December workbooks, I want to enter either a 1 or a 2 in the InputBox, and then for the code to either update only the "DEC18" worksheet, or, update all the monthly sheets, while ignoring any sheets that are not the 'monthly' sheets. The same code (which works for a single sheet as it is written now) needs to be run, but only for the sheet(s) 'identified' by having entered either a 1 or 2.
I can't wrap my head around what combo of For Each, Do ___, If, etc. would work best to do this.
So far, I have written this snippet:
Code:
'''''sAns = InputBox("Do you want to make ROUND formula updates in ""DEC18"" sheet ONLY, or, ALL PII sheets?" & _
''''' vbNewLine & vbNewLine & _
''''' "Enter 1 for DEC18 sheet ONLY" & _
''''' vbNewLine & _
''''' "Enter 2 for ALL PII sheets", _
''''' "Update which sheets?", 1)
'''''
'''''If sAns = "" Then 'if 'Cancel' button pressed, Exit Sub
''''' Exit Sub
'''''Else
'''''End If
'''''
'''''If ws.Name = "DEC18" And sAns = 1 Then
'''''For Each ws In Worksheets 'includes any hidden sheets
''''' If ws.Name Like "[A-Z][A-Z][A-Z]##" Then 'if sheet name matches the pattern [AAA##], i.e 3 UPPER CASE alpha, followed by 2 numeric
Any thoughts that would get me pointed in a different (better!) direction? Thanks!