Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 2 of 2

Thread: Determining Number of Rows in Worksheet

  1. #1
    Join Date
    1st February 2005
    Posts
    1

    Determining Number of Rows in Worksheet

    Hi,

    I need to be able to deterimine that last row in a worksheet that contains data. The number of columns is fixed but the rows will vary. Once I have the number or rows, I can set the "Printarea" property correctly which is what I need to do. I'm sure this is an easy one but it is escaping me. Any help would be greatly appreciated. Thanks.

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    14th July 2004
    Posts
    10,539

    Re: Determining Number of Rows in Worksheet

    There are various methods of finding the last row of data.

    One of them is the following:
    VB:
    Dim LastRow As Long 
     
    LastRow = ActiveSheet.Range("A65536").End(xlUp).Row 
    
    
    See the attached file.

    The code behind the command button is:
    VB:
     
    Private Sub CommandButton1_Click() 
        Dim LastRow As Long 
        Dim ws As Worksheet 
        Set ws = ActiveSheet 
        LastRow = ws.Range("A65536").End(xlUp).Row 
         
        With ws.PageSetup 
            .PrintArea = "A1:E" & LastRow 
        End With 
    End Sub 
    
    
    Attached Files. REMINDER! OzGrid accepts no responsibility for ANY adverse effects as a result from downloading attached files. ALWAYS run an up-to-date virus scan and disable macros.

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Calculate number of rows used on Sheet/Worksheet
    By tornado in forum EXCEL HELP
    Replies: 13
    Last Post: May 31st, 2006, 00:28
  2. limit number of rows in worksheet
    By mickdonedee in forum EXCEL HELP
    Replies: 2
    Last Post: November 6th, 2005, 05:31
  3. Determining the number of Used Rows in a WorkSheet . . .
    By bdonkersgoed in forum EXCEL HELP
    Replies: 9
    Last Post: October 21st, 2005, 02:43

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
  •  
porno