Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Changing the textbox value without changing the textbox format?

Hello,
I have a userform with text boxes and I assign values from cells like below:
UserForm1.TextBox1.value = Sheets("Calculation").Range("A1").value
UserForm1.TextBox1.text = Sheets("Calculation").Range("A1").text

However when I change the code later to something like this:
UserForm1.TextBox1.value = Sheets("Calculation").Range("B1").value

Not only is the value updated/changed but the format is gone also.
How can I set the format/text only one time (on activate of userform for
example) so that I don't need to set the format everytime?

Thank you,
Ozgur
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Changing the textbox value without changing the textbox format?

Ozgur,

Is there a reason why you need to use the .Value statements? In your
code below you are overwriting any value you display in the TextBox.
If you use just the .Text statement for formatting is preserved.

Let's say Cell A1 has a value of 55.3333 and it is formatted as
"$55.3". When you use the .Value statement below followed immediately
by the .Text statement, you would display "$55.3". You would be
overwriting the value of 55.3333 that you had just put there.

Mark


Ozgur Pars wrote:
Hello,
I have a userform with text boxes and I assign values from cells like below:
UserForm1.TextBox1.value = Sheets("Calculation").Range("A1").value
UserForm1.TextBox1.text = Sheets("Calculation").Range("A1").text

However when I change the code later to something like this:
UserForm1.TextBox1.value = Sheets("Calculation").Range("B1").value

Not only is the value updated/changed but the format is gone also.
How can I set the format/text only one time (on activate of userform for
example) so that I don't need to set the format everytime?

Thank you,
Ozgur


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Changing the textbox value without changing the textbox format

Mark,
you are totaly right I somehow assumed that I have to first get the .value
and then do the formating with the .text and never questioned the reasoning
behind it later.
Thanks your help now I can get rid of the .values and save time and resources.

Appreciate your effort,
Ozgur

"Mark Driscol" wrote:

Ozgur,

Is there a reason why you need to use the .Value statements? In your
code below you are overwriting any value you display in the TextBox.
If you use just the .Text statement for formatting is preserved.

Let's say Cell A1 has a value of 55.3333 and it is formatted as
"$55.3". When you use the .Value statement below followed immediately
by the .Text statement, you would display "$55.3". You would be
overwriting the value of 55.3333 that you had just put there.

Mark


Ozgur Pars wrote:
Hello,
I have a userform with text boxes and I assign values from cells like below:
UserForm1.TextBox1.value = Sheets("Calculation").Range("A1").value
UserForm1.TextBox1.text = Sheets("Calculation").Range("A1").text

However when I change the code later to something like this:
UserForm1.TextBox1.value = Sheets("Calculation").Range("B1").value

Not only is the value updated/changed but the format is gone also.
How can I set the format/text only one time (on activate of userform for
example) so that I don't need to set the format everytime?

Thank you,
Ozgur



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
Changing textbox properties from Access VBA justme0010[_4_] Charts and Charting in Excel 0 March 11th 08 02:22 AM
ActiveX textBox : value doesn't show after programatically changing the value Philippe[_6_] Excel Programming 1 June 2nd 06 10:37 AM
Changing font color of textbox text..... jan Excel Programming 5 January 31st 05 08:10 PM
Changing text to numberformat via textbox on a form Stef Excel Programming 3 June 22nd 04 02:33 PM
changing a text value to a number value in a textbox? reb Excel Programming 4 April 20th 04 02:11 AM


All times are GMT +1. The time now is 11:59 PM.

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"