+ Reply to Thread
Results 1 to 4 of 4

Macro to count rows

  1. #1
    Registered User
    Join Date
    06-23-2010
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007
    Posts
    9

    Macro to count rows

    Hi,
    I have a macro to count the rows in a report, the macro does many other things as well.
    Please Login or Register  to view this content.
    This works perfectly if i have more than two rows, but if i only have 2 rows i get:
    Run-time error '1004'
    AutoFill method of Range class failed, I'm guessing its because the range is A14:A14.
    I'm using this macro within templates which are attached to reports within our application, so I'd prefer to avoid declaring variables as xlsm templates cannot be used by all our users.
    Anyone have any simple tweaks I can do to make this work when the range is one row?
    Any help would be appreciated.
    Thanks!
    Attached Files Attached Files
    Last edited by Excel Outsider; 08-05-2010 at 02:31 PM.

  2. #2
    Registered User
    Join Date
    07-01-2010
    Location
    Portland, OR, USA
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Macro to count rows

    This is really crude, but works (on my computer at least).

    Please Login or Register  to view this content.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to count rows

    How about this:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    06-23-2010
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Macro to count rows

    I had some other code so I couldn't use the end Sub with the first count, I updated to
    Please Login or Register  to view this content.
    Once again thanks everyone for all your help!

+ 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