Value NOT placed in 2 sheets, but in ALL others

C

Corey

Sub Workbook_Info()
On Error Resume Next
With Sheets("1:50")
' If sheet is NOT sheet1 or sheet3 then
..Select
ActiveSheet.Unprotect
Range("R59").Select
ActiveCell.FormulaR1C1 = "=MAX('Page 1:" & Worksheets(Worksheets.Count).Name & "'!R[0]C[-8])"
ActiveSheet.protect DrawingObjects:=True, Contents:=True, Scenarios:=True,
AllowFormattingCells:=True
End With
End Sub

The above code places the MAX value in cell R59 in ALL sheets in my workbook.
But i have discovered that i DO NOT want it to be placed in 2 sheets of the workbook.
Sheet1 and Sheet3.

How can skip sheet1 and 3 so they are not included in the code above?

Corey....
 
N

Nigel

You need to loop through each sheet bypassing the ones you do not wish to
add the formula.

Dim X as Long
For X = 2 to 50
With Worksheets(X)
If .Name <> "Sheet3" then
.Unprotect
.Range("R59").FormulaR1C1 = "=MAX('Page 1:" &
Worksheets(Worksheets.Count).Name & "'!R[0]C[-8])"
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True,
AllowFormattingCells:=True
End If
Next X
 

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