I don't think it's that difficult.
For each named range, the .Row property is the first Row.
.Rowheight is the number of rows in the named range.
.column is the first column
.columnwidth is the number of columns.

So, for Range: "Sheet1Data"

    rLast = Range("Sheet1Data").Row + Range("Sheet1Data").RowHeight
    cFirst = Range("Sheet1Data").Column
    cLast = cFirst + Range("Sheet1Data").ColumnWidth
    Sheets("Sheet1").Range(Cells(rLast, cFirst), Cells(rLast, 
cLast)).Borders(xlEdgeBottom).LineStyle = xlContinuous

Paul


----- Original Message ----
> From: Kurt <heislerk...@gmail.com>
> To: MS EXCEL AND VBA MACROS <excel-macros@googlegroups.com>
> Sent: Fri, November 5, 2010 10:28:46 AM
> Subject: $$Excel-Macros$$ Macro to add bottom border to cells in range
> 
> I have several dynamic named ranges that span multiple worksheets. The
> ranges are named Sheet1Data, Sheet2Data ... up to Sheet4Data.
> 
> I need to create a macro that applies a bottom border to the last row
> in each range. I've taken some code that loops through the *cells* in
> each range (Dim c As Range), and tried to adapt it to look only at the
> last row. But I need some help with the For Each syntax. Here's what I
> have so far:
> 
> Public Sub AddBorder()
> 
>     Dim i As Integer
>     Dim c As Range
>     Dim LastRow As Long
> 
>     ' Cycle through each Named Range
>     For i = 1 To 4
>         ' Cycle through each range
>         For Each c In Range("Sheet" & i & "Data")
>           ' Identify the last row, and create a LastRow variable
>           LastRow = Range("Sheet" & i & "Data").End(xlUp).Row
>           ' Apply a bottom border to the last row in the range
>           Range("Comp" & i & "Measures" &
> LastRow).Borders(xlEdgeBottom).LineStyle = xlContinous
>         Next c
>     Next i
> 
> End Sub
> 
> ###
> 
> Thanks for any advice.
> 
> -- 
>----------------------------------------------------------------------------------
>-
> Some important links for excel users:
> 1. Follow us on TWITTER for tips tricks and links : 
>http://twitter.com/exceldailytip
> 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
> 3. Excel tutorials at http://www.excel-macros.blogspot.com
> 4. Learn VBA Macros at http://www.quickvba.blogspot.com
> 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
> 
> To post to this group, send email to excel-macros@googlegroups.com
> 
> <><><><><><><><><><><><><><><><><><><><><><>
> Like our page on facebook , Just follow below link
> http://www.facebook.com/pages/discussexcelcom/160307843985936?v=wall&ref=ts
> 

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/pages/discussexcelcom/160307843985936?v=wall&ref=ts

Reply via email to