Hello,
I am trying to write a VBA that selects (from the ActiveWorkbook) each sheet that is not named "Engine" Or "Runs". After the sheet is selected, the code will find the word "Total" within my range and will highlight the row from column A:P and go to the next sheet not named "Engine" or "Runs" and perform the same function. I can get the code to work to do one or the other, but not both. If anyone out there knows what I am doing wrong and how to fix it, I would greatly appreciate the help.
Sub Find_Total_Cells()
Dim myRange As Range
Dim myCell As Range
Set myRange = Range("A6:A1000")
For Each myCell In myRange
Dim Sht As Worksheet 'new
For Each Sht In ActiveWorkbook.Worksheets 'new
If myCell Like "*Total*" And Sht.Name <> "Runs" Or Sht.Name <> "Engine" Then
Sht.Select
myCell.EntireRow.Font.Bold = True
myCell.Columns("D:P").Value = "Sum Formula Needed"
With myCell.Columns("A:P").Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent4
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
End If
Next myCell
Next Sht
End Sub
I am trying to write a VBA that selects (from the ActiveWorkbook) each sheet that is not named "Engine" Or "Runs". After the sheet is selected, the code will find the word "Total" within my range and will highlight the row from column A:P and go to the next sheet not named "Engine" or "Runs" and perform the same function. I can get the code to work to do one or the other, but not both. If anyone out there knows what I am doing wrong and how to fix it, I would greatly appreciate the help.
Sub Find_Total_Cells()
Dim myRange As Range
Dim myCell As Range
Set myRange = Range("A6:A1000")
For Each myCell In myRange
Dim Sht As Worksheet 'new
For Each Sht In ActiveWorkbook.Worksheets 'new
If myCell Like "*Total*" And Sht.Name <> "Runs" Or Sht.Name <> "Engine" Then
Sht.Select
myCell.EntireRow.Font.Bold = True
myCell.Columns("D:P").Value = "Sum Formula Needed"
With myCell.Columns("A:P").Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent4
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
End If
Next myCell
Next Sht
End Sub