Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Tricky Macro Coding Question

I have a macro that churns down through a column of dates ("For Each cel in
Selection...") and accumulates (count and sum) certain information from that
row. When the macro reaches the end of a month, I need it to transfer the
accumulated values to another area of the spreadsheet, then zero out the
"accumulator" cells and start over again for the new month.

My problem is that the area the accumulated values are moved to is itself a
range corresponding to months; if the accumulated values are for January I
need to put them under January, if they're for April they go under April, and
so on. I can do that with another "For Each cel" selection routine, but that
breaks the connection to the ORIGINAL selection, causing me to in effect
"lose my place" in that column of dates.

Can anybody suggest how to move the accumulated values to the correct
position in my months range while remembering where I was in the dates range
and resuming the process from that point?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Tricky Macro Coding Question

You could probably do what you want if instead of the For Each...Next loop
you would use:

For i = (beginning row number) To (ending row number) 'substitute your values
If Cells(i, ColNbr) = (month) Then
'copy data range to appropriate location, etc.
End If
Next i


That way you could tell where i is because it moves from top to bottom
sequentially.
However, if your source range is not contained in one column, this would not
work.


"LarryP" wrote:

I have a macro that churns down through a column of dates ("For Each cel in
Selection...") and accumulates (count and sum) certain information from that
row. When the macro reaches the end of a month, I need it to transfer the
accumulated values to another area of the spreadsheet, then zero out the
"accumulator" cells and start over again for the new month.

My problem is that the area the accumulated values are moved to is itself a
range corresponding to months; if the accumulated values are for January I
need to put them under January, if they're for April they go under April, and
so on. I can do that with another "For Each cel" selection routine, but that
breaks the connection to the ORIGINAL selection, causing me to in effect
"lose my place" in that column of dates.

Can anybody suggest how to move the accumulated values to the correct
position in my months range while remembering where I was in the dates range
and resuming the process from that point?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Tricky Macro Coding Question

Okay, makes sense; I'll give it a go. Thanks!

"JLGWhiz" wrote:

You could probably do what you want if instead of the For Each...Next loop
you would use:

For i = (beginning row number) To (ending row number) 'substitute your values
If Cells(i, ColNbr) = (month) Then
'copy data range to appropriate location, etc.
End If
Next i


That way you could tell where i is because it moves from top to bottom
sequentially.
However, if your source range is not contained in one column, this would not
work.


"LarryP" wrote:

I have a macro that churns down through a column of dates ("For Each cel in
Selection...") and accumulates (count and sum) certain information from that
row. When the macro reaches the end of a month, I need it to transfer the
accumulated values to another area of the spreadsheet, then zero out the
"accumulator" cells and start over again for the new month.

My problem is that the area the accumulated values are moved to is itself a
range corresponding to months; if the accumulated values are for January I
need to put them under January, if they're for April they go under April, and
so on. I can do that with another "For Each cel" selection routine, but that
breaks the connection to the ORIGINAL selection, causing me to in effect
"lose my place" in that column of dates.

Can anybody suggest how to move the accumulated values to the correct
position in my months range while remembering where I was in the dates range
and resuming the process from that point?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro/VB coding question melExcel2007 Excel Discussion (Misc queries) 3 June 4th 10 11:16 PM
Tricky Macro Question Philip Excel Worksheet Functions 4 December 30th 09 05:40 PM
New guy with a tricky question Arian Goodwin Excel Programming 3 November 10th 05 03:45 PM
Implant macro coding into ASP coding Sam yong Excel Programming 5 September 15th 05 10:37 AM
Tricky Question The Boondock Saint Excel Worksheet Functions 7 December 8th 04 07:22 PM


All times are GMT +1. The time now is 02:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"