R
ryguy7272
I found this tiny macro on the web and I was trying to modify it for my
purposes, which basically includes finding and selecting cells with the word
‘Total’ and placing a boarder around cells in that same row, STARTING one
column to the right and six columns to the right of that.
Sub AddBorders()
'start cell
Range("J1:J500").Select
Do Until ActiveCell = Empty
If Cells = "*Total" Then
Selection.Offset(0, 1).Select
ActiveCell.Offset(0, 6).Select
Selection.Borders(xlEdgeLeft).LineStyle = xlContinuous
Selection.Borders(xlEdgeTop).LineStyle = xlContinuous
Selection.Borders(xlEdgeBottom).LineStyle = xlContinuous
Selection.Borders(xlEdgeRight).LineStyle = xlContinuous
End If
Loop
End Sub
Obviously the macro doesn’t work (or I wouldn’t be posting here). It fails
on this line:
If Selection = "*Total" Then
What am I doing wrong?
Regards,
Ryan---
purposes, which basically includes finding and selecting cells with the word
‘Total’ and placing a boarder around cells in that same row, STARTING one
column to the right and six columns to the right of that.
Sub AddBorders()
'start cell
Range("J1:J500").Select
Do Until ActiveCell = Empty
If Cells = "*Total" Then
Selection.Offset(0, 1).Select
ActiveCell.Offset(0, 6).Select
Selection.Borders(xlEdgeLeft).LineStyle = xlContinuous
Selection.Borders(xlEdgeTop).LineStyle = xlContinuous
Selection.Borders(xlEdgeBottom).LineStyle = xlContinuous
Selection.Borders(xlEdgeRight).LineStyle = xlContinuous
End If
Loop
End Sub
Obviously the macro doesn’t work (or I wouldn’t be posting here). It fails
on this line:
If Selection = "*Total" Then
What am I doing wrong?
Regards,
Ryan---