This code is working well. I want to improve it.
I have two goals.
I cannot make any impact when i try to solve this, which makes me think it needs a different approach if I am going to achieve it.
1. it currently requires a range to be entered. eg. bt2:bt
For Each xrg In Range("bt2:bt" & LastRow - 1)
I am trying to get it to work on the "selection" -which in practice would normallly be the selection of an entire column
for eg, something like a
with selection
'code in here'
end with
may work, but did not work for me.
2. with this required range for the choice of how far the border extends (left to right) eg. LK
Range("A" & xrg.row & ":LK" & xrg.row).BORDERS(xlEdgeBottom).Weight = xlMedium
Can this be set to choose the "LastColumn (last column or cell used) plus the next 50 columns" and not require the actual cell reference to be input.
Hope someone can help, Thanks in advance.
I have two goals.
I cannot make any impact when i try to solve this, which makes me think it needs a different approach if I am going to achieve it.
1. it currently requires a range to be entered. eg. bt2:bt
For Each xrg In Range("bt2:bt" & LastRow - 1)
I am trying to get it to work on the "selection" -which in practice would normallly be the selection of an entire column
for eg, something like a
with selection
'code in here'
end with
may work, but did not work for me.
2. with this required range for the choice of how far the border extends (left to right) eg. LK
Range("A" & xrg.row & ":LK" & xrg.row).BORDERS(xlEdgeBottom).Weight = xlMedium
Can this be set to choose the "LastColumn (last column or cell used) plus the next 50 columns" and not require the actual cell reference to be input.
Hope someone can help, Thanks in advance.
VBA Code:
Sub BORDER_CRITERIA()
'CREATES A ROW BORDER AT THE POINT WHERE THERE IS A CELL CHANGE WITHIN A COLUMN
Application.ScreenUpdating = False
Dim LastRow As Long
Dim xrg As Range
LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
For Each xrg In Range("bt2:bt" & LastRow - 1)
If xrg <> xrg.Offset(1, 0) Then
Range("A" & xrg.row & ":LK" & xrg.row).BORDERS(xlEdgeBottom).Weight = xlMedium
End If
Next xrg
Application.ScreenUpdating = True
End Sub