Adding a border to a variable range

RobertSi

New Member
Joined
Oct 15, 2015
Messages
4
For i = 1 To 1000
If Sheets("Income List").Range("A" & i + 2) <> blank Then
Range("A1:N&i").Borders.LineStyle = xlContinuous
End If
Next

I have also tried

For i = 1 To 1000
If Sheets("Income List").Range("A" & i + 2) <> blank Then
Range("A1:N"&i).Borders.LineStyle = xlContinuous
End If
Next

This is what I want to do but I'm unsure of how to accomplish what I want. There is code that populates a list and then I want the list to get a border around the list. The list has a fixed number of columns but the row numbers will vary and therefore I was hoping the above code would work but unfortunately not.

Any help would be great thanks
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Perhaps.
Code:
With Sheets("Income List")
    .Range("A3:N" & .Range("A" & Rows.Count).End(xlUp).Row).Borders.LineStyle = xlContinuous
End With
 
Upvote 0

Forum statistics

Threads
1,215,943
Messages
6,127,826
Members
449,411
Latest member
adunn_23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top