You know , I think I just worked it out. It did not seem to like the reference to I46 as it is a calc reference from sheet 1 $E$31. when I pointed it to E31 on sheet 1, it started to work. Standby however, I need to extrapolate this code and make sure I can pull it off for up to 6 carriage boxes.
Sub AddBorders()
With Sheets("Shop Order")
' The following code works with page 2 of the shop order worksheet specifically with System B.
' In this first if statement, it is assumed that system B will not be in use at all.
If .Range("A73") = "" Then
.Range("C72:N74").Borders.LineStyle = 0 'this comment clears out all boxes for system B
End If
' the following code creates one thick outline box because this carriage will have only one section.
If .Range("A73") <> "" And Sheets("Start - User Inputs").Range("$E$31") = 1 Then
.Range("E72:N74").Borders.LineStyle = 0 ' This line clears out all boxes for system B after the first carriage box
With .Range("C72:D74") ' This line draws in 1 thick border box spanning two columns and three rows.
' Remove all diagonal borders
.Borders(5).LineStyle = xlNone
.Borders(6).LineStyle = xlNone
.Borders(11).LineStyle = xlNone
.Borders(12).LineStyle = xlNone
' Add borders around each cell
For i = 7 To 10
With .Borders(i)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
Next i
End With
End If
End With
End Sub
Thank you for teaching me VBA code.
Bookmarks