Some VBA functions not working in Excel 97

larsson7

New Member
Joined
Jul 23, 2002
Messages
18
Hello,

A workbook that I have created in Excel 2000 contains some functions in the VBA code that will not run in Excel 97. These functions are round() and formatCurrency() among others.

Is there any way of getting them to run in Excel 97, or is there an altenative?

Thankyou for your time.

Regards,

Cameron
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi,

Instead of FormatCurrency you should be able to use Format e.g.

Sub TestOfFormat()
Dim x
x = 100200.23
MsgBox Format(x, "$#,##0.00;($#,##0.00)")
End Sub

As for Round, I didn't know that was only added in Excel 97 (it's been a long time since I saw it/used it). I would double check that Round doesn't work because I don't recall it being new in Excel 2000/XP. If not, here's one possibility.

Sub TestOfRound()
Dim p As Double
p = 3.14159265358979

MsgBox WorksheetFunction.Round(p, 2)
End Sub
 
Upvote 0
...and, one can always fall back to that old BASIC method of rounding:

NumToRound = 123.4567
d = 2 'number of decimals desired
NumRounded = Int(NumToRound*10^d+0.5)/10^d

Success to you!
 
Upvote 0
Hello and thankyou for your replies,

I have tried out the 'format' function specified above and it works perfectly!

I have also used the BASIC rounding technique, which seems to be more efficient than the round function anyway.

Once again, many thanks to you all.

Regards,

Cameron
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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