View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
STEVE BELL STEVE BELL is offline
external usenet poster
 
Posts: 692
Default Can anybody crack this VBA problem?

Ken,

When I took a close look - they weren't really equal...
There were trailing spaces of different lengths. Trim didn't seem to work,
but Cdbl did...

--
steveB

Remove "AYN" from email to respond
"Ken Wright" wrote in message
...
Why not just use Conditional formatting to make the font white of any
entry
that equals the one to the right?

Assuming your data is in B2:M11, you select B2:M10, do Format /
Conditional
formatting, change 'cell value is' to 'formula is' and then put in B2=C2,
choose a white font and hit OK.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------

"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