Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Number format in vba

I have the following code for passing some data on to a user form:

Private Sub UserForm_Initialize()
Me.TextBox1.Value = Sheets("Blend Sheet").Range("ac7").Value

End Sub

Works fine except for one thing - I am getting a number in my text box that
has 12 decimal places.
How do I format so the value returned only has 2 decimals?

Regards
gregork


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Number format in vba

Hi gregork,

What kind of data is in A7

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Number format in vba

You could control the format explicitly, like:

Me.TextBox1.Value = format(Sheets("Blend Sheet").Range("ac7").Value,"0.00")

or you could pick up what's displayed in the worksheet:

Me.TextBox1.Value = Sheets("Blend Sheet").Range("ac7").Text



gregork wrote:

I have the following code for passing some data on to a user form:

Private Sub UserForm_Initialize()
Me.TextBox1.Value = Sheets("Blend Sheet").Range("ac7").Value

End Sub

Works fine except for one thing - I am getting a number in my text box that
has 12 decimal places.
How do I format so the value returned only has 2 decimals?

Regards
gregork


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Number format in vba

one way:

Me.TextBox1.Value = Format(Sheets("Blend Sheet").Range("ac7").Value, _
"0.00")


In article ,
"gregork" wrote:

I have the following code for passing some data on to a user form:

Private Sub UserForm_Initialize()
Me.TextBox1.Value = Sheets("Blend Sheet").Range("ac7").Value

End Sub

Works fine except for one thing - I am getting a number in my text box that
has 12 decimal places.
How do I format so the value returned only has 2 decimals?

Regards
gregork


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I add phone number format as a permanent custom format? frustratedagain Excel Discussion (Misc queries) 3 February 4th 06 03:52 AM
Replace million-billion number format to lakhs-crores format Sumit Excel Discussion (Misc queries) 1 December 9th 05 04:58 PM
Change number (in text format) to numeric format Pam Excel Discussion (Misc queries) 5 October 24th 05 07:45 PM
convert text-format number to number in excel 2000%3f Larry Excel Discussion (Misc queries) 1 July 29th 05 08:18 PM
excel format cells/Number/Category: Number problem Matts Excel Discussion (Misc queries) 5 December 9th 04 09:47 PM


All times are GMT +1. The time now is 08:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"