+ Reply to Thread
Results 1 to 4 of 4

Count Number of full rows

  1. #1
    Jamie
    Guest

    Count Number of full rows

    Hi There

    I am looking to write a macro that opens a spreadsheet, looks at the number
    of rows that are occupied by data, then selects the next blank cell to paste
    a new line of data from another spreadsheet.

    Is this possible?

    Jamie

  2. #2
    Registered User
    Join Date
    08-18-2004
    Posts
    16
    Provided that the rows of data are consecutive (no blank rows) you can use the CountA function to find the last row with data. To get the next one, simply add 1 to it. To call the CountA function in VBA use:
    Application.WorksheetFunctions.CountA

    Post back if you need a code sample.

  3. #3
    Herbert
    Guest

    RE: Count Number of full rows

    Hi Jamie!

    You can determine the next empty row with:
    Dim nNewRow As Long

    nNewRow = ActiveSheet.UsedRange.Rows.Count + ActiveSheet.UsedRange.Row - 1

    I hope this helps.

    Herbert


    "Jamie" wrote:

    > Hi There
    >
    > I am looking to write a macro that opens a spreadsheet, looks at the number
    > of rows that are occupied by data, then selects the next blank cell to paste
    > a new line of data from another spreadsheet.
    >
    > Is this possible?
    >
    > Jamie


  4. #4
    Herbert
    Guest

    RE: Count Number of full rows

    Oh my, I am getting old!

    The correct formula is:
    nNewRow = ActiveSheet.UsedRange.Rows.Count + ActiveSheet.UsedRange.Row

    Sorry for that!

    Herbert

    "Herbert" wrote:

    > Hi Jamie!
    >
    > You can determine the next empty row with:
    > Dim nNewRow As Long
    >
    > nNewRow = ActiveSheet.UsedRange.Rows.Count + ActiveSheet.UsedRange.Row - 1
    >
    > I hope this helps.
    >
    > Herbert
    >
    >
    > "Jamie" wrote:
    >
    > > Hi There
    > >
    > > I am looking to write a macro that opens a spreadsheet, looks at the number
    > > of rows that are occupied by data, then selects the next blank cell to paste
    > > a new line of data from another spreadsheet.
    > >
    > > Is this possible?
    > >
    > > Jamie


+ Reply to 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