Forum Discussion

GEEK_21's avatar
GEEK_21
Brass Contributor
Mar 06, 2023
Solved

Exclude VBA from running on a sheet | Help !

Hello everyone. so I have a Workbook with 6 sheets named 1 2 3 4 5

and a sheet named B and I have a VBA code and I want it to run only

on the five sheets and exclude sheet B

 

 

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

If Not Application.Intersect(Target, Range("A3:T50")) Is Nothing Then

Range("A3:T50").Interior.ColorIndex = xlColorIndexNone

Target.EntireRow.Interior.ColorIndex = 36

Target.Interior.Color = RGB(255, 160, 122)

End If

End Sub

 

 

 

 

2 Replies

  • JKPieterse's avatar
    JKPieterse
    Silver Contributor
    Add this as the first line:
    If Sh.Name = "B" Then Exit Sub

Resources