Hello,
The code below does what I want, it adds boarders to ranges in sections that contain text. If a row is blank, is doesn’t add the boarders which is exactly what I want it to do. However, I don’t want to be on the active sheet and trying to work around the Select and Selection commands.
I cant seem to get past this line:
Full Code
Any help is appreciated
The code below does what I want, it adds boarders to ranges in sections that contain text. If a row is blank, is doesn’t add the boarders which is exactly what I want it to do. However, I don’t want to be on the active sheet and trying to work around the Select and Selection commands.
I cant seem to get past this line:
VBA Code:
WS.Range(Cells(R, c), Cells(R, lngLstCol)).Select
Full Code
VBA Code:
Sub addboarders()
Application.ScreenUpdating = False
Dim lngLstCol As Long, lngLstRow As Long
Dim WS As Worksheet
Set WS = Sheet4
lngLstRow = WS.UsedRange.Rows.Count
lngLstCol = WS.UsedRange.Columns.Count
For Each rngCell In WS.Range("A2:A" & lngLstRow)
If rngCell.Value > "" Then
R = rngCell.Row
c = rngCell.Column
WS.Range(Cells(R, c), Cells(R, lngLstCol)).Select
With Selection.Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End If
Next
Application.ScreenUpdating = True
End Sub
Any help is appreciated