Ironman
Well-known Member
- Joined
- Jan 31, 2004
- Messages
- 1,069
- Office Version
- 365
- Platform
- Windows
Hi
I used the macro recorder to create part of the macro below to outline the selected cell in red but it seems a bit clunky.
Can this be shortened?
Also, I'd be grateful if a couple of lines could be added so it will not outline more than 1 cell at any one time.
Many thanks!
I used the macro recorder to create part of the macro below to outline the selected cell in red but it seems a bit clunky.
VBA Code:
Sub Outline()
If ActiveSheet.Name <> "Training 1981-1997" Then
MsgBox "You clicked this by mistake!" & vbNewLine & vbNewLine & _
"This function will only run in" & vbNewLine & _
"Training 1981-1997 sheet", vbInformation, "Function Invalid In This Sheet"
Exit Sub
End If
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Color = -16776961
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Color = -16776961
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Color = -16776961
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Color = -16776961
.Weight = xlMedium
End With
End Sub
Also, I'd be grateful if a couple of lines could be added so it will not outline more than 1 cell at any one time.
Many thanks!