Closed Thread
Results 1 to 4 of 4

Last row on every page

Hybrid View

  1. #1
    Registered User
    Join Date
    04-26-2007
    Posts
    77

    Last row on every page

    Dear Sir,

    How to findout LastRow on every page in sheet.

    http://www.vbaexpress.com/forum/showthread.php?t=13260

    Actually I want to apply following border to lastrow of every sheet page

     With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
    Please help
    Last edited by VBA Noob; 06-13-2007 at 08:43 AM.

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Here is several ways to find the last used row & column

    'find row before next blank cell in column A
    iLastRow = Range("A1").End(xlDown).Row
    
    'find last used row in column A
    iLastRow = Cells(Rows.Count, "a").End(xlUp).Row
    
    'find last used row on sheet
    iLastRow = Cells.Find(what:="*", SearchOrder:=xlByRows, _
    SearchDirection:=xlPrevious).Row
    
    'find column before next blank cell in row 1
    iLastColumn = Range("A1").End(xlToRight).Column
    
    'find last used column in row 1
    iLastColumn = Cells(1, Columns.Count).End(xlToLeft).Column
    
    'find last used column on sheet
    iLastColumn = Cells.Find(what:="*", SearchOrder:=xlByColumns, _
    SearchDirection:=xlPrevious).Column
    
    'set variable to last used cell
    Dim rLC As Range
    Set rLC = ActiveSheet.UsedRange
    
    Set rLC = ActiveCell.SpecialCells(xlLastCell)
    With rows(iLastRow).Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hope this i not another cross post ??

    Also if you want to post here please reply to your other posts.


    The below will run on the last cell in Col A for each sht which may not be what you want

    Could try usedrange...see link

    http://www.rondebruin.nl/last.htm#one

    Sub LastCellInColA()
        Dim LastRow As Long
        Dim sh As Worksheet
        Dim i As Integer
        Dim FirstSht As Worksheet
        Set FirstSht = ActiveSheet
        For i = 1 To Worksheets.Count
        Sheets(i).Select
        With ActiveSheet
            LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
        End With
       With Range(LastRow & ":" & LastRow).Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        Next i
    FirstSht.Select
    End Sub
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    tqm1 ,

    Thinks for agreeing to folow the rules. I've posted the cross link for you

    http://www.vbaexpress.com/forum/showthread.php?t=13260

    VBA Noob

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1