I am trying to apply a thick border to the left side of the same cells on every worksheet given that the cell has a specific value. So if the cell says "P12" then apply a thick border to the left side of that cell and of the underneath cells to0, in my case C2:C7, otherwise apply a normal size border to the left side. It works only for the first sheet but doesn't apply to every sheet in the workbook. I haven't added any code for the thin border as I was just wanting to test it for the thick border to begin.
I am new to VBA so I can't seem to see why it won't work. I may have made the code I have posted below more complicated that it needs to be. I have included the offset and this may not be necessary.
This is my code so far:
Sub Border_For_P12_Loop_All_Sheets() Dim shts, ws As Excel.Worksheet shts = Array("Sheet1", "Sheet2", "Sheet3") For Each ws In Sheets Range("C1").Select Do If ActiveCell <> "p12" Then ActiveCell.Offset(1, 0).Select Else: ActiveCell.Value = "p12" Range("C2:C7").Select With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlMedium End With ActiveCell.Offset(1, 0).Select End If Loop Until ActiveCell = Range("C28") Next End Sub