VBA - formatting numbers

Spurious

Active Member
Joined
Dec 14, 2010
Messages
439
I got a bit weird question:

I am downloading exchange rates from a website, Euro:Yen is different than Euro:USD, the first is xxx.xx, the former x.xxxx. In both cases I want to kill the last two digits.

Since it's a macro and I sometimes download Yen FX rates and sometimes USD FX rates, I cant use round.

Anyone got any solution?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
This will delete the last two digits in the active cell. You could write additional vba to loop until all cells in the column have been checked.

Code:
ActiveCell = Left(ActiveCell, Len(ActiveCell) - 2)<!-- google_ad_section_end -->

You could also use a formula to do this:

=LEFT(A1,LEN(A1)-2)
 
Last edited:
Upvote 0
This will delete the last two digits in the active cell. You could write additional vba to loop until all cells in the column have been checked.

Code:
ActiveCell = Left(ActiveCell, Len(ActiveCell) - 2)

Thanks, this doesnt really solve my problem, though.

I will provide 4 examples of exchange rates:

Code:
1014.6
113.37
86.856
1.4563

Now, I want to check one value and then determine what the format is.
For the last 3, finding where the dot is, will be sufficient and I would be able to round using x digits after the dot, but the first one should be rounded from 1014.6 to 1010.

So, I guess in the end I want to have the following:

Code:
1014.6 --> 1010
113.37 --> 113
86.856 --> 86.9
1.4563 --> 1.46

Does that make sense?
 
Upvote 0
I'm sorry, I thought you simply wanted to kill the last two digits. Let me take a look at it again.
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,820
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top