When i give th following
mysht.columns(13).numberformat ="0.00"
i get following results in column 13 763.00 instead of 763.44
1830.00 instead of 1829.52
Pl help me get the exact results
Regards
Samyo
Printable View
When i give th following
mysht.columns(13).numberformat ="0.00"
i get following results in column 13 763.00 instead of 763.44
1830.00 instead of 1829.52
Pl help me get the exact results
Regards
Samyo
VB Code:
Private Sub Command1_Click() Dim oneVal oneVal = Val(Text1) Dim twoVal twoVal = Val(Form2) Dim GROWVal GROWVal = Val(Text1) + Val(Text2) MsgBox "YOUR TOTAL IS $" & Format(GROWVal, "0.00"), , "OK TO EXIT" End Sub
Use this...
Works fine for me in a new worksheet.VB Code:
mySht.Columns(13).NumberFormat = "0.00" 'Or mySht.Columns("M").NumberFormat = "0.00"
Moved
Somehow does not work it rounds off to .00 and exact decimal nos i dont get after decimal places
regds
Samyo
How are you executing the code and do you have anyother formatting code on it?
I believe you have to declare it as variable number in stead - so it will be
I you wan't to put in 1,000 separators, then you can do like this #,#,#.## for instance.VB Code:
mysht.columns(13).numberformat ="#.##"
Try experimenting using the format cells --> custom in your worksheet - it should give you a clue of what you can do...
posted code in #3 works correct and rounds to two places after the decimal point.
Enable macros and check out column "M". enter in some numbers with at least to the thousandths.
Containing code:
VB Code:
Option Explicit Private Sub Workbook_Open() Sheet1.Columns("M").NumberFormat = "0.00" End Sub