+ Reply to Thread
Results 1 to 2 of 2

Decoding an old macro

  1. #1
    WendiL99
    Guest

    Decoding an old macro

    I'm trying to understand and simplify an enormous macro that was written in
    1999. I came across a section that I don't understand what it is doing. The
    macro is

    'Neg Amounts (AccDep, GnLss, Purch only)...Other Accounts Count
    Range("A1").Select
    Range("A2").Select
    AccountsCost = 0
    Do While ActiveCell.Range("A1") > 0
    AccountsCost = AccountsCost + 1
    ActiveCell.Offset(1, 0).Range("A1").Select
    Loop
    Range("A1").Select

    A sample of the data:

    Co Acct Sum Of Expr1
    3342010 16,295.00
    3344010 382,039.00
    3348010 100,467.00
    4300010 466,752.00
    4302010 62,314.00

    Can someone tell me what this is doing? Thanks!!


  2. #2
    Bob Phillips
    Guest

    Re: Decoding an old macro

    It just counts how many cells from A2 down have a value > 0. It can be done
    simpler with


    AccountsCost = Application.CountIf(Range("A2:A" &
    Range("A2").End(xlDown).Row), ">0")

    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "WendiL99" <WendiL99@discussions.microsoft.com> wrote in message
    news:3A7496A9-FBDA-4BDB-B8F8-A01451A0659C@microsoft.com...
    > I'm trying to understand and simplify an enormous macro that was written

    in
    > 1999. I came across a section that I don't understand what it is doing.

    The
    > macro is
    >
    > 'Neg Amounts (AccDep, GnLss, Purch only)...Other Accounts Count
    > Range("A1").Select
    > Range("A2").Select
    > AccountsCost = 0
    > Do While ActiveCell.Range("A1") > 0
    > AccountsCost = AccountsCost + 1
    > ActiveCell.Offset(1, 0).Range("A1").Select
    > Loop
    > Range("A1").Select
    >
    > A sample of the data:
    >
    > Co Acct Sum Of Expr1
    > 3342010 16,295.00
    > 3344010 382,039.00
    > 3348010 100,467.00
    > 4300010 466,752.00
    > 4302010 62,314.00
    >
    > Can someone tell me what this is doing? Thanks!!
    >




+ 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