+ Reply to Thread
Results 1 to 4 of 4

Variable number of rows in a macro

  1. #1
    Registered User
    Join Date
    10-03-2011
    Location
    Milano
    MS-Off Ver
    Excel 2007
    Posts
    17

    Variable number of rows in a macro

    Hi all!

    I'm trying to write a macro with a variable number or rows depending on the total number of rows the workbook has.

    I tried like this:

    Please Login or Register  to view this content.
    but it gives me an error. The only way i was able to do it without error was:

    Please Login or Register  to view this content.
    but as u can see it has a fixed number of rows.

    I'm not a 'pro' programmer in excel, i'm just starting learning, so any help is really appreciated!

    thanks

  2. #2
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: Variable number of rows in a macro

    use the below code to get the number of used rows (r as an integer)

    Please Login or Register  to view this content.

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Variable number of rows in a macro

    Please Login or Register  to view this content.

    Avoid Select & Activate in VBA



  4. #4
    Registered User
    Join Date
    10-03-2011
    Location
    Milano
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Variable number of rows in a macro

    I tried this:

    Please Login or Register  to view this content.
    and also copy and pasted the solution of snb but in both cases i have an error at the Application.Run step (I guess when calling the number or rows/columns).

    any ideas? thanks a lot ^^

+ 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