Macro should not Run For Sheet1 , Sheet2 & Sheet3

Chandresh

Board Regular
Joined
Jul 21, 2009
Messages
146
HI Team

need help

below macro is running for all the sheet , could you please help with the code so that it should not run for Sheet1,Sheet2,Sheet3



Sub Test111()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Activate
Range("A500").Select
ActiveCell.FormulaR1C1 = "=R[-497]C"
Range("b499").Select
ActiveCell.FormulaR1C1 = "Tax Liability"
Range("c499").Select
ActiveCell.FormulaR1C1 = "Realised"
Range("B500").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-1]C,R[-499]C[-1]:R[-6]C[1],3,0)"
Range("C500").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-1]C,R[-499]C[-2]:R[-2]C[2],4,0)"
Range("C500").Select
Next
End sub



Thanks in advance for help
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Here is one way
Rich (BB code):
For Each ws In ThisWorkbook.Worksheets
  Select Case ws.Name
    Case "Sheet1", "Sheet2", "Sheet3"
      'Do nothing
    Case Else
      'The rest of your code goes here

  End Select
Next
 
Upvote 0
Try this.
Code:
Sub Test111()
Dim ws As Worksheet

    For Each ws In ThisWorkbook.Worksheets
    
        With ws
            Select Case .Name
                Case "Sheet1", "Sheet2", "Sheet3"
                ' do nothing
                Case Else
                    .Range("A500").FormulaR1C1 = "=R[-497]C"
                    .Range("b499").Value = "Tax Liability"
                    .Range("c499").Value = "Realised"
                    .Range("B500").FormulaR1C1 = "=VLOOKUP(R[-1]C,R[-499]C[-1]:R[-6]C[1],3,0)"
                    .Range("C500").FormulaR1C1 = "=VLOOKUP(R[-1]C,R[-499]C[-2]:R[-2]C[2],4,0)"
            End Select
        
        End With
    Next ws
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top