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

I have a form that allows users to input data into cells in various
worksheets. When requested the form takes data from the cells it will write
to if the user chooses as "first value". What I would like to do is format
the text boxes so that the numbers taken from the spreadsheet are presented a
certain way ( one decimal place or as a % etc). Can I do this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Number formatting in forms

Hi Brian

The following code is straight out of the excel vba help file, it
should give you a clear idea of how to do what you are after.

' User-defined formats.
MyStr = Format(5459.4, "##,##0.00") ' Returns "5,459.40".
MyStr = Format(334.9, "###0.00") ' Returns "334.90".
MyStr = Format(5, "0.00%") ' Returns "500.00%".
MyStr = Format("HELLO", "<") ' Returns "hello".
MyStr = Format("This is it", "") ' Returns "THIS IS IT".


I hope this helps you out

Steve

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Number formatting in forms

Not really ( or at least I can't see how it does). Might need more
explanation about what I've got...

Example from my code:

Mix_Constraints_Form.comp1_min.Value = Worksheets("Results").Cells(17,
7).Value

This sets the value in the form equal to the value in the cell of the
worksheet referenced and the user can enter a value into the form and
overwrite back to the worksheet if chosen.

This works fine, but the values taken from the worksheet are displayed in
the form unformatted. (for example in the worksheet the value from above
could be displayed as 49% but the form might show .494213871 value from the
worksheet when I want to display 49% in the form as well).


"Incidental" wrote:

Hi Brian

The following code is straight out of the excel vba help file, it
should give you a clear idea of how to do what you are after.

' User-defined formats.
MyStr = Format(5459.4, "##,##0.00") ' Returns "5,459.40".
MyStr = Format(334.9, "###0.00") ' Returns "334.90".
MyStr = Format(5, "0.00%") ' Returns "500.00%".
MyStr = Format("HELLO", "<") ' Returns "hello".
MyStr = Format("This is it", "") ' Returns "THIS IS IT".


I hope this helps you out

Steve


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Number formatting in forms

Hi Brian

Sorry for the late reply, the code below is shows the value .494213871
as 49% using the format function.

With Mix_Constraints_Form

..comp1_min.Value = Format(Worksheets("Results") _
..Cells(17, 7).Value, "0%")

End With

You can change the format to reflect what you want. I'm not exactly
sure what exactly your aim is with this but i hope you see where i'm
coming from with this. You said in your first post you wanted to show
as one decimal place as well, excel rounds .494213871 up to 0.5 if you
format the cell to one decimal place. You can do that in code like so

With Mix_Constraints_Form

..comp1_min.Value = Format(Worksheets("Results") _
..Cells(17, 7).Value, "0.0")

End With

I hope this is more clear for you

Steve

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Number formatting in forms

That is clearer. Thanks for the help.

"Incidental" wrote:

Hi Brian

Sorry for the late reply, the code below is shows the value .494213871
as 49% using the format function.

With Mix_Constraints_Form

..comp1_min.Value = Format(Worksheets("Results") _
..Cells(17, 7).Value, "0%")

End With

You can change the format to reflect what you want. I'm not exactly
sure what exactly your aim is with this but i hope you see where i'm
coming from with this. You said in your first post you wanted to show
as one decimal place as well, excel rounds .494213871 up to 0.5 if you
format the cell to one decimal place. You can do that in code like so

With Mix_Constraints_Form

..comp1_min.Value = Format(Worksheets("Results") _
..Cells(17, 7).Value, "0.0")

End With

I hope this is more clear for you

Steve




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Number formatting in forms

On Apr 4, 8:49*pm, Brian wrote:
That is clearer. *Thanks for the help.



"Incidental" wrote:
Hi Brian


Sorry for the late reply, the code below is shows the value .494213871
as 49% using the format function.


With Mix_Constraints_Form


..comp1_min.Value = Format(Worksheets("Results") _
..Cells(17, 7).Value, "0%")


End With


You can change the format to reflect what you want. *I'm not exactly
sure what exactly your aim is with this but i hope you see where i'm
coming from with this. *You said in your first post you wanted to show
as one decimal place as well,excelrounds .494213871 up to 0.5 if you
format the cell to one decimal place. *You can do that in code like so


With Mix_Constraints_Form


..comp1_min.Value = Format(Worksheets("Results") _
..Cells(17, 7).Value, "0.0")


End With


I hope this is more clear for you


Steve- Hide quoted text -


- Show quoted text -


Try this... Instead of using cell.value use cell.text that would help
you.

Prabodh Shetty
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
Formatting in Forms Amy Excel Worksheet Functions 2 March 8th 07 08:32 PM
How do i automaticaly number consecutive forms Stan O. Terry Excel Worksheet Functions 2 February 8th 07 03:02 AM
Formatting textbox in forms control Ken Valenti Excel Programming 1 April 22nd 06 04:10 AM
Forms and Conditional Formatting limited computer knowledge Excel Worksheet Functions 2 April 29th 05 04:30 PM
Number in forms Alvin Hansen[_2_] Excel Programming 7 November 24th 04 04:20 PM


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

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

About Us

"It's about Microsoft Excel"