PC Review


Reply
 
 
Sal
Guest
Posts: n/a
 
      18th May 2009
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 With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      18th May 2009
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
(E-Mail Removed)
"Sal" <(E-Mail Removed)> wrote in message
news:566ED49B-2F51-4FB5-9F22-(E-Mail Removed)...
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
border on last cell of page effects border on beginning cell of ne GaryE Microsoft Excel Misc 0 23rd Mar 2009 05:47 AM
Changing the border of one cell s/n change the border of adjacent =?Utf-8?B?Z2phbnNzZW5tbg==?= Microsoft Excel Misc 2 5th Oct 2005 08:35 PM
only last cell on page to have bottom border (cell area outline) =?Utf-8?B?V2lnZ3Vt?= Microsoft Excel Worksheet Functions 1 29th Apr 2005 03:53 PM
Body of page appears in Top Border, Left Border and Bottom Border (there is no right border) Michael Edwards Microsoft Frontpage 1 14th Oct 2004 09:46 AM
How can I add border to a cell michelle_ho Microsoft Excel Programming 3 11th Mar 2004 11:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:05 PM.