View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Paul Paul is offline
external usenet poster
 
Posts: 25
Default Find the nearest point to 1000 rows where "amounts" balance and apply special formatting to that row

Hi,

I'm writing a macro to create a csv file from a spreadsheet that has to be
formatted in a certain way.

One rule for the csv I'm getting stuck on is as follows:

The speadsheet could contain say 20000 lines. The fields could be Journal
number, description, Amount.

As I extract each row, the code should find the nearest row to 1000 where
the amounts evaluate to zero (the amounts are pluses and minuses) at which
point I can apply specific fomating to that row in the csv extract then to
start the count again from 1 and find the next nearest row to 1000 and again
apply the specific formatting to that row in the csv extract.

I'm thinking that I could step through each row and add the amounts (amount
= amount + amount) but the problem is the formatting should occur at the
NEAREST point to 1000 rows as possible. How do I get the code to count back
from 1000 to find that point if when I'm adding the amounts I'm starting
from 1 and counting up.

Any advise appreciated

Paul