Sub findbordr()
Dim r As Long
r = 1
Dim c As Long
c = 1
Do Until r > 46
If Cells(r, c).Interior.ColorIndex <> xlNone Then
If Cells(r, c).Offset(0, 1).Interior.ColorIndex = xlNone Then
Cells(r, c).Borders(xlEdgeRight).LineStyle = xlContinuous
End If
If c = 1 Then
Cells(r, c).Borders(xlEdgeLeft).LineStyle = xlContinuous
c = c + 1
End If
If Cells(r, c).Offset(0, -1).Interior.ColorIndex = xlNone Then
Cells(r, c).Borders(xlEdgeLeft).LineStyle = xlContinuous
c = c + 1
Else:
c = c + 1
If c > 52 Then
c = 1
r = r + 1
End If
End If
Else:
c = c + 1
If c > 52 Then
r = r + 1
c = 1
End If
End If
Loop
Call findbordt
End Sub
Sub findbordt()
Dim r As Long
r = 2
Dim c As Long
c = 2
Do Until r > 46
If Cells(r, c).Interior.ColorIndex <> xlNone Then
If Cells(r, c).Offset(1, 0).Interior.ColorIndex = xlNone Then
Cells(r, c).Borders(xlEdgeBottom).LineStyle = xlContinuous
End If
If Cells(r, c).Offset(-1, 0).Interior.ColorIndex = xlNone Then
Cells(r, c).Borders(xlEdgeTop).LineStyle = xlContinuous
c = c + 1
Else:
c = c + 1
If c > 52 Then
c = 1
r = r + 1
End If
End If
Else:
c = c + 1
If c > 52 Then
r = r + 1
c = 1
End If
End If
Loop
End Sub
Post-Indent
Sub findbordr()
Dim r As Long
r = 1
Dim c As Long
c = 1
Do Until r > 46
If Cells(r, c).Interior.ColorIndex <> xlNone Then
If Cells(r, c).Offset(0, 1).Interior.ColorIndex = xlNone Then
Cells(r, c).Borders(xlEdgeRight).LineStyle = xlContinuous
End If
If c = 1 Then
Cells(r, c).Borders(xlEdgeLeft).LineStyle = xlContinuous
c = c + 1
End If
If Cells(r, c).Offset(0, -1).Interior.ColorIndex = xlNone Then
Cells(r, c).Borders(xlEdgeLeft).LineStyle = xlContinuous
c = c + 1
Else:
c = c + 1
If c > 52 Then
c = 1
r = r + 1
End If
End If
Else:
c = c + 1
If c > 52 Then
r = r + 1
c = 1
End If
End If
Loop
Call findbordt
End Sub
Sub findbordt()
Dim r As Long
r = 2
Dim c As Long
c = 2
Do Until r > 46
If Cells(r, c).Interior.ColorIndex <> xlNone Then
If Cells(r, c).Offset(1, 0).Interior.ColorIndex = xlNone Then
Cells(r, c).Borders(xlEdgeBottom).LineStyle = xlContinuous
End If
If Cells(r, c).Offset(-1, 0).Interior.ColorIndex = xlNone Then
Cells(r, c).Borders(xlEdgeTop).LineStyle = xlContinuous
c = c + 1
Else:
c = c + 1
If c > 52 Then
c = 1
r = r + 1
End If
End If
Else:
c = c + 1
If c > 52 Then
r = r + 1
c = 1
End If
End If
Loop
End Sub
It took me a moment to catch the issue lies with Else:. I think the : causes it to be perceived as a line label but it compiles and does run. Removing : produces correct indentation.
While reviewing the tweeted article https://twitter.com/rubberduckvba/status/986058407013646336 I pasted the code in the indenter and didn't get correct indentation.
Pre-indent
Post-Indent
It took me a moment to catch the issue lies with
Else:
. I think the:
causes it to be perceived as a line label but it compiles and does run. Removing:
produces correct indentation.