Jul 19th, 2006, 10:31 PM
#1
Thread Starter
Member
NumberFormat
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
Jul 19th, 2006, 10:53 PM
#2
Addicted Member
Re: NumberFormat
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
Jul 19th, 2006, 11:05 PM
#3
Re: NumberFormat
Use this...
VB Code:
mySht.Columns(13).NumberFormat = "0.00"
'Or
mySht.Columns("M").NumberFormat = "0.00"
Works fine for me in a new worksheet.
Moved
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jul 19th, 2006, 11:32 PM
#4
Thread Starter
Member
Re: NumberFormat
Somehow does not work it rounds off to .00 and exact decimal nos i dont get after decimal places
regds
Samyo
Jul 19th, 2006, 11:35 PM
#5
Re: NumberFormat
How are you executing the code and do you have anyother formatting code on it?
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jul 20th, 2006, 01:57 AM
#6
Lively Member
Re: NumberFormat
I believe you have to declare it as variable number in stead - so it will be
VB Code:
mysht.columns(13).numberformat ="#.##"
I you wan't to put in 1,000 separators, then you can do like this #,#,#.## for instance.
Try experimenting using the format cells --> custom in your worksheet - it should give you a clue of what you can do...
Jul 20th, 2006, 02:01 AM
#7
Re: NumberFormat
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
Attached Files
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width