Hello Everyone,
Not an extremely needed tool but I feel that there will be some that will find this useful.
I was able to record the following two macros below (seems like so much coding for something so simple).
The first one adds an X (using diagonal Borders lines) to selected cells and the second one removes this X from selected cells.
I was wondering if someone would be able to combine these two into one macro using "IF" syntax.
So if there isn't an X this macro will add it to the selected cell(s) and if an X does exist in the selected cell(s) remove it.
I tried adding the "if" and the "else" myself but yeah I don't know what I am doing
Adds X
Removes X
Not an extremely needed tool but I feel that there will be some that will find this useful.
I was able to record the following two macros below (seems like so much coding for something so simple).
The first one adds an X (using diagonal Borders lines) to selected cells and the second one removes this X from selected cells.
I was wondering if someone would be able to combine these two into one macro using "IF" syntax.
So if there isn't an X this macro will add it to the selected cell(s) and if an X does exist in the selected cell(s) remove it.
I tried adding the "if" and the "else" myself but yeah I don't know what I am doing
Adds X
Code:
Sub AddX()
With Selection.Borders(xlDiagonalDown)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
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
With Selection.Borders(xlDiagonalDown)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlDiagonalUp)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
End Sub
Removes X
Code:
Sub RemoveX()
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
With Selection.Borders(xlDiagonalUp)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
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
End Sub
Last edited: