Thread
:
Can anybody crack this VBA problem?
View Single Post
#
2
Posted to microsoft.public.excel.programming
Don Guillett[_4_]
external usenet poster
Posts: 2,337
Can anybody crack this VBA problem?
use a for/each looping macro within another for/each macro
--
Don Guillett
SalesAid Software
"Alex" wrote in message
...
Hello
Here is the problem. I have 10 products of which the prices may change
each
month. I keep monthly records going back 12 months. It looks like this...
Prod May-05 Apr-05 Mar-05 Feb-05 Jan-05 Dec-04
etc...
A $100 $100 $100 $90 $90 $100
B $90 $90 $90 $80 $80 $90
C $85 $85 $85 $70 $70
$80
D $60 $60 $60 $60 $60 $70
etc..
The above table would extend back to Apr 04 (i.e. 12 months) and go down
to
product J. (i.e. 10 products).
In some instances the prices do not change month to month. e.g. May, Apr,
Mar are all the same. However in Feb the prices are different. In other
words
there was a price change in MARCH-05 .
I have tried in vain to write some VBA code that will go thorugh the table
and leave only the months where price changes occurred.
So the code would start in the first column (May-05) and compare prices
for
all products (A-H) with the prior month. If they are the same then the
code
will remove(.clearcontents) the prior month and then move onto the next
month. If the prices are different then those prices will remain the in
the
table and then those prices will be used to compare against prior months
to
check for price changes.
In the end the table should contain only those columns where a price
change
occured from the previous month.
In the example I give above the remaining columns would be Mar-05, Jan-05,
and Dec-04 as they show different pricing structures.
Looked at another way, I don't want any columns that have the same pricing
schedule. I just want a sequential representation of how prices have
changed.
If anybody has any ideas then I would enjoy reading them. I have got
halfway
throught the problem but then get stuck. It is simple to see if this
months
column is the same as the prior month and delete if the same. But it gets
more complicated. Again, in the table above, you would start at Mar-05 and
clear the contents of Apr-05 as it is the same pricing structure. But then
you cannot move on to comparing Apr-05 with Mar-05. You need to still use
May-05 to compare with Mar-05.
I hope I have made it clear what I am trying to acheive. Please write back
if you need more information.
As always in this support community, any guidance is warmly received.
Best Regards
Alex
Reply With Quote
Don Guillett[_4_]
View Public Profile
Find all posts by Don Guillett[_4_]