BORDERS

  • Thread starter Thread starter ghamilton
  • Start date Start date
G

ghamilton

I have spreadsheets which vary in number of rows. I want to put a
border around all the records in column b starting at row 2 and to the
bottom of the sheet. Then I want to put another border around column
c through column o also starting at row 2. The columns will not ever
change just the number of rows.

Thanks for the help,
 
This will handle columns C-O on one sheet. I leave the rest to you.

Hth,
Merjet

Sub DoBorders()
Dim rng As Range
Dim c As Range
Dim iEnd As Long

iEnd = Sheets("Sheet1").Range("C65536").End(xlUp).Row

'clear any borders in range
Set rng = Sheets("Sheet1").Range("C2:O" & iEnd)
For Each c In rng
c.Borders(xlEdgeTop).LineStyle = xlNone
c.Borders(xlEdgeLeft).LineStyle = xlNone
c.Borders(xlEdgeRight).LineStyle = xlNone
c.Borders(xlEdgeBottom).LineStyle = xlNone
Next c

'add left borders
Set rng = Sheets("Sheet1").Range("C2:C" & iEnd)
For Each c In rng
c.Borders(xlEdgeLeft).LineStyle = xlContinuous
c.Borders(xlEdgeLeft).Weight = xlThick
Next c

'add bottom borders
Set rng = Sheets("Sheet1").Range("C" & iEnd & ":" & "O" & iEnd)
For Each c In rng
c.Borders(xlEdgeBottom).LineStyle = xlContinuous
c.Borders(xlEdgeBottom).Weight = xlThick
Next c

'add right borders
Set rng = Sheets("Sheet1").Range("O2:O" & iEnd)
For Each c In rng
c.Borders(xlEdgeRight).LineStyle = xlContinuous
c.Borders(xlEdgeRight).Weight = xlThick
Next c

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top