Macro Help - 2 sets of sheet array

S

Steve Klenner

I've had the following macro that has been working fine:

Sub MISalesTAX_Profile()
Application.ScreenUpdating = False
Dim sht As Worksheet
For Each sht In Sheets(Array("Sheet2", "Sheet3")) 'Selects sheet
sht.Unprotect Password:="lock" 'Unlock sheet
sht.Range("G57").FormulaR1C1 = "=R[-1]C*6%" 'Inputs 6% to Cell G57
sht.Range("F57").FormulaR1C1 = "MI Sales Tax" 'Inputs MI Sales Tax to Cell F57
sht.Protect Password:="lock" 'Locks Sheet
Next sht 'Next Sheet in Array
Sheets("Sheet1").Select 'Go to Sheet 1
Application.ScreenUpdating = True
End Sub

I'd like to do below......but it is NOT working: The Macro Doesn't Fail but it does not update Sheet4 and Sheet5
How do I get the Macro to follow the second set of sheet array's?

Sub MISalesTAX_Profile()
Application.ScreenUpdating = False
Dim sht As Worksheet
For Each sht In Sheets(Array("Sheet2", "Sheet3")) 'Selects sheet
sht.Unprotect Password:="lock" 'Unlock sheet
sht.Range("G57").FormulaR1C1 = "=R[-1]C*6%" 'Inputs 6% to Cell G57
sht.Range("F57").FormulaR1C1 = "MI Sales Tax" 'Inputs MI Sales Tax to Cell F57
sht.Protect Password:="lock" 'Locks Sheet
Next sht 'Next Sheet in Array
***********************************************************************************************************************************
For Each sht In Sheets(Array("Sheet4, "Sheet5")) 'Selects sheet
sht.Unprotect Password:="lock" 'Unlock sheet
sht.Range("G129").FormulaR1C1 = "=R[-1]C*6%" 'Inputs 6% to Cell G129
sht.Range("F129").FormulaR1C1 = "MI Sales Tax" 'Inputs MI Sales Tax to Cell F129
sht.Protect Password:="lock" 'Locks Sheet
Next sht 'Next Sheet In Array
***********************************************************************************************************************************
Sheets("Sheet1").Select 'Go to Sheet 1
Application.ScreenUpdating = True
End Sub

Thanks for any HELP!!!!!

Steve
 
G

Guest

Steve,
Worked OK for me. I noted an error in your code but that might
just be a typo in NG submission as it should be VBE syntax error:

For Each sht In Sheets(Array("Sheet4, "Sheet5")) .. missing Quote "

should be

For Each sht In Sheets(Array("Sheet4", "Sheet5"))


Steve Klenner said:
I've had the following macro that has been working fine:

Sub MISalesTAX_Profile()
Application.ScreenUpdating = False
Dim sht As Worksheet
For Each sht In Sheets(Array("Sheet2", "Sheet3")) 'Selects sheet
sht.Unprotect Password:="lock" 'Unlock sheet
sht.Range("G57").FormulaR1C1 = "=R[-1]C*6%" 'Inputs 6% to Cell G57
sht.Range("F57").FormulaR1C1 = "MI Sales Tax" 'Inputs MI Sales Tax to Cell F57
sht.Protect Password:="lock" 'Locks Sheet
Next sht 'Next Sheet in Array
Sheets("Sheet1").Select 'Go to Sheet 1
Application.ScreenUpdating = True
End Sub

I'd like to do below......but it is NOT working: The Macro Doesn't Fail but it does not update Sheet4 and Sheet5
How do I get the Macro to follow the second set of sheet array's?

Sub MISalesTAX_Profile()
Application.ScreenUpdating = False
Dim sht As Worksheet
For Each sht In Sheets(Array("Sheet2", "Sheet3")) 'Selects sheet
sht.Unprotect Password:="lock" 'Unlock sheet
sht.Range("G57").FormulaR1C1 = "=R[-1]C*6%" 'Inputs 6% to Cell G57
sht.Range("F57").FormulaR1C1 = "MI Sales Tax" 'Inputs MI Sales Tax to Cell F57
sht.Protect Password:="lock" 'Locks Sheet
Next sht 'Next Sheet in Array
***********************************************************************************************************************************
For Each sht In Sheets(Array("Sheet4, "Sheet5")) 'Selects sheet
sht.Unprotect Password:="lock" 'Unlock sheet
sht.Range("G129").FormulaR1C1 = "=R[-1]C*6%" 'Inputs 6% to Cell G129
sht.Range("F129").FormulaR1C1 = "MI Sales Tax" 'Inputs MI Sales Tax to Cell F129
sht.Protect Password:="lock" 'Locks Sheet
Next sht 'Next Sheet In Array
***********************************************************************************************************************************
Sheets("Sheet1").Select 'Go to Sheet 1
Application.ScreenUpdating = True
End Sub

Thanks for any HELP!!!!!

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top