I wrote the following VBA macro that cycles through different border formats each time a unique keyboard shortcut is pressed. It is supposed to progress from a thin solid bottom border, to a thick solid bottom border, to a double-line bottom border, then return to "no border." It works as intended except for the last step. I can write the macro such that it goes from a thick, solid bottom border to no border, but following the same logic doesn't work when trying to go from the double-line bottom border to no border.
Please advise.
Sub borderCycle()
' borderCycle Macro
' Macro recorded 1/17/2012 by wongand1
' Keyboard Shortcut: Ctrl+Shift+B
With Selection
'//Add thin solid bottom border
If (Selection.Borders(xlEdgeBottom).LineStyle = xlNone) Then
Selection.Borders(xlEdgeBottom).LineStyle = xlContinuous
Selection.Borders(xlEdgeBottom).Weight = xlThin
Selection.Borders(xlEdgeBottom).ColorIndex = xlAutomatic
'//Add thick solid bottom border
ElseIf (Selection.Borders(xlEdgeBottom).Weight = xlThin) Then
Selection.Borders(xlEdgeBottom).LineStyle = xlContinuous
Selection.Borders(xlEdgeBottom).Weight = xlThick
Selection.Borders(xlEdgeBottom).ColorIndex = xlAutomatic
'//Add thick double bottom border
ElseIf (Selection.Borders(xlEdgeBottom).Weight = xlThick) Then
Selection.Borders(xlEdgeBottom).LineStyle = xlDouble
Selection.Borders(xlEdgeBottom).Weight = xlThick
Selection.Borders(xlEdgeBottom).ColorIndex = xlAutomatic
' //(trying to remove thick, double bottom edge border)
ElseIf (Selection.Borders(xlEdgeBottom).LineStyle = xlDouble) Then
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Please advise.
Sub borderCycle()
' borderCycle Macro
' Macro recorded 1/17/2012 by wongand1
' Keyboard Shortcut: Ctrl+Shift+B
With Selection
'//Add thin solid bottom border
If (Selection.Borders(xlEdgeBottom).LineStyle = xlNone) Then
Selection.Borders(xlEdgeBottom).LineStyle = xlContinuous
Selection.Borders(xlEdgeBottom).Weight = xlThin
Selection.Borders(xlEdgeBottom).ColorIndex = xlAutomatic
'//Add thick solid bottom border
ElseIf (Selection.Borders(xlEdgeBottom).Weight = xlThin) Then
Selection.Borders(xlEdgeBottom).LineStyle = xlContinuous
Selection.Borders(xlEdgeBottom).Weight = xlThick
Selection.Borders(xlEdgeBottom).ColorIndex = xlAutomatic
'//Add thick double bottom border
ElseIf (Selection.Borders(xlEdgeBottom).Weight = xlThick) Then
Selection.Borders(xlEdgeBottom).LineStyle = xlDouble
Selection.Borders(xlEdgeBottom).Weight = xlThick
Selection.Borders(xlEdgeBottom).ColorIndex = xlAutomatic
' //(trying to remove thick, double bottom edge border)
ElseIf (Selection.Borders(xlEdgeBottom).LineStyle = xlDouble) Then
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone