Link to home
Start Free TrialLog in
Avatar of MikeMCSD
MikeMCSDFlag for United States of America

asked on

Want to Update the Price field and format digits after decimal point in xls.

I have a "our_price" Column field that contains values like : 50.22, 8.78, 68.19, etc.

I want to do 2 things:

1. Raise all prices in the "our_price" field by 18%

2. I want the last 2 digits after the decimal point to be rounded like this :

If :  .01 to .29  =  .29

If :  .30 to .49  =  .49

If :  .50 to .99  =  .95

So if  the price is "29.14", it would be "29.29", . . . "18.78" would be "18.99", etc.

Can I combine these 2 queries at once? Or should I run 2 separate queries?

I'm using Excel Starter 2010,  and a :  Excel 97 - 2003 Workbook ( *.xls)

I'm not good at Exel at all, so the more detailed instructions the better.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Flyster
Flyster
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MikeMCSD

ASKER

thanks Flyster, . .  How do I "run" it?
You just paste it into any cell. It will automatically "run" when you enter a value in A1, or whatever cell you want.
What I have is a sheet that already has 500 rows,
and each column already has the price (like 2.88, 55.44, etc.) in it.

I pasted it in a few columns, and it displays : #NAME?
What do I do in this situation?

Say your prices are in A1-A500. In B1 paste the formula above. Now copy that cell, B1, and paste it down to B500. Once pasted, the formula will adjust to the corresponding cells. Just make sure you modify the original formula to reflect the cell with your price, if it isn't already A1.
Hopefully the above will work for you. I have to leave for a bit. Will check back later.
Another way to do this, using VLOOKUP:

=INT(A2*1.18)+VLOOKUP(MOD(A2*1.18,1),{0,0;0.01,0.29;0.3,0.49;0.5,0.95},2)

Using that big array constant as the lookup table can be confusing, so I usually recommend setting up a lookup table on another worksheet.  So, if you have a worksheet named Lookup, you could enter these in A1:B5...

Start Decimal      Round To
0.00       0.00
0.01       0.29
0.30       0.49
0.50       0.95

My formula above then becomes:

=INT(A2*1.18)+VLOOKUP(MOD(A2*1.18,1),Lookup!$A$2:$B$5,2)

If you are using Excel 2007/2010 and set up that lookup range as a Table, or in any version if you set it up as a named range:

=INT(A2*1.18)+VLOOKUP(MOD(A2*1.18,1),NameOfTableOrRange,2)

For more about VLOOKUP, please see:

https://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/A_2637-Six-Reasons-Why-Your-VLOOKUP-or-HLOOKUP-Formula-Does-Not-Work.html
thanks Matt, but I don't understand anything about Excel or formulas, and don't really know how to use that.

>>  In B1 paste the formula above. Now copy that cell, B1, and paste it down to B500.  

There is a field in B1 already. The next empty field is CY1.
I tried selecting that column range and pasting the formula but it give a message saying "the clipboard is larger . . ".


OK, let's try again :)

What is the first cell with an original price in it, and what is the first available, unpopulated column?

Based on your comment above, it looks like the first available column is CY.

If the first available price is in A1, then put this in CY1:

=INT(A1*1.18)+VLOOKUP(MOD(A1*1.18,1),{0,0;0.01,0.29;0.3,0.49;0.5,0.95},2)

If the first available price is in A2, then put this in CY2:

=INT(A2*1.18)+VLOOKUP(MOD(A2*1.18,1),{0,0;0.01,0.29;0.3,0.49;0.5,0.95},2)

If the first available price is in W2, then put this in CY2:

=INT(W2*1.18)+VLOOKUP(MOD(W2*1.18,1),{0,0;0.01,0.29;0.3,0.49;0.5,0.95},2)

You get the idea :)

Once you do that, select the cell where you entered the formula, and hit Ctrl+C to copy.  Now select the range you would need to copy that formula to, and hit Enter.
thanks Matt, . .  that worked but put the new values into the CY column.
I need the original prices that are in E2 - E500 changed. They are still displaying the original value.


=INT(E2*1.18)+VLOOKUP(MOD(E2*1.18,1),{0,0;0.01,0.29;0.3,0.49;0.5,0.95},2)

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
perfect
thanks for the help guys
I'm glad it worked out for you. Thanks.