#1   Report Post  
Posted to microsoft.public.excel.programming
Sal Sal is offline
external usenet poster
 
Posts: 84
Default Cell Border

This Macro creates borders around Columns A:O. It stops creating borders at
the last row in Colum O that has contents. Can I get help changing it so
that it stops creating borders at the last row that has contents in Column A
or Column B or Column C or Column D or Column E or Column F or Column G or
Column H or Column I or Column J or Column K or Column L or Column M or
Column N or Column O?

Sub Border ()
With Range("A1:O" & Range("O" & Rows.Count).End(xlUp).Row)
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
End With
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Cell Border

Try this,
Sub shortestcolumnforborders()
lr = Cells.Find("*", Cells(Rows.Count, _
Columns.Count), , , xlByRows, xlPrevious).Row
'MsgBox lr

For i = 1 To 16
clr = Cells(Rows.Count, i).End(xlUp).Row
'MsgBox clr
If clr < lr Then lr = clr
Next i
Cells(1, 1).Resize(lr, 16). _
Borders.LineStyle = xlContinuous
'MsgBox lr 'minrow
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Sal" wrote in message
...
This Macro creates borders around Columns A:O. It stops creating borders
at
the last row in Colum O that has contents. Can I get help changing it so
that it stops creating borders at the last row that has contents in Column
A
or Column B or Column C or Column D or Column E or Column F or Column G or
Column H or Column I or Column J or Column K or Column L or Column M or
Column N or Column O?

Sub Border ()
With Range("A1:O" & Range("O" & Rows.Count).End(xlUp).Row)
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
End With
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
border on last cell of page effects border on beginning cell of ne GaryE Excel Discussion (Misc queries) 0 March 23rd 09 05:47 AM
Changing the border of one cell s/n change the border of adjacent gjanssenmn Excel Discussion (Misc queries) 2 October 5th 05 08:35 PM
Cell Border Gary's Student Excel Discussion (Misc queries) 2 June 9th 05 12:40 PM
only last cell on page to have bottom border (cell area outline) Wiggum Excel Worksheet Functions 1 April 29th 05 03:53 PM
outside cell border Jenna Excel Discussion (Misc queries) 1 February 14th 05 10:35 PM


All times are GMT +1. The time now is 03:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"