I'm attempting to write my first VBA code. I have several worksheets in one workbook and I need to apply the code to 8 specific worksheets based on worksheet name. Within each worksheet, I need to delete several rows based on fill color (there's no conditional formatting). I have the basic code below that seems to work when I apply it to just one worksheet but the colored rows are spread throughout the sheets and I can't figure out how to loop it correctly so that it deletes all of the required rows. It also doesn't seen to work when I add in the other worksheet names. I'm not opposed to replicating the code for each worksheet but there are 8 of them and I have a hunch that there's an easier way.
To sum it up, I need this code to apply to 8 worksheets within the same workbook and it needs to loop through the worksheet to delete every row with specific fill colors.
Thanks in advance!Sub DeleteRows() With Application .Calculation = xlCalculationManual .EnableEvents = False .ScreenUpdating = False End With Worksheets("Sheet1").Select Dim cell As Range For Each Row In Selection If Row.Interior.Color = RGB(144, 238, 144) Then Row.EntireRow.Delete End If Next Row For Each Row In Selection If Row.Interior.Color = RGB(175, 238, 238) Then Row.EntireRow.Delete End If Next Row With Application .Calculation = xlCalculationManual .EnableEvents = True .ScreenUpdating = True End With End Sub