Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
cincode5
 
Posts: n/a
Default VBA Text Box: How To Load Different Text

Hello,

I would like to use a VBA Text Box to display different sets of messages
that can be invoked from various other VBA sub routines. For example, if
someone uses a Pull Down menu to select a User ID, I would llike to use the
Pull Down's Sub Routine to assign a message using Text_Box.Text =
Range("???##").Text.

I don't know if this is the best way to change the contents of a Text Box,
but if someone out there more familiar with VBA can help me to understand the
correct procedure for accomplishing this, I would be greatful for the insight.

--
Regards...
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

This is on a userform?

I put a combobox and a textbox on a userform. I used this code:

Option Explicit
Private Sub ComboBox1_Change()
Me.TextBox1.Value = Worksheets("sheet1").Range("a1").Text
End Sub

Private Sub UserForm_Initialize()
Dim iCtr As Long
For iCtr = 1 To 10
Me.ComboBox1.AddItem "asdf" & iCtr
Next iCtr
End Sub

====
You may also want to consider using a label--instead of a textbox.


cincode5 wrote:

Hello,

I would like to use a VBA Text Box to display different sets of messages
that can be invoked from various other VBA sub routines. For example, if
someone uses a Pull Down menu to select a User ID, I would llike to use the
Pull Down's Sub Routine to assign a message using Text_Box.Text =
Range("???##").Text.

I don't know if this is the best way to change the contents of a Text Box,
but if someone out there more familiar with VBA can help me to understand the
correct procedure for accomplishing this, I would be greatful for the insight.

--
Regards...


--

Dave Peterson
  #3   Report Post  
cincode5
 
Posts: n/a
Default

Thanks Dave... You seem to be bailing me out of delimmas more frequently.

I'm slowly coming to understand VBA, and when I wrote this post I was
stiffled by what I believe is a sharing issue between Modules and code that
resides in worksheet subroutines. The subroutine for the textbox is not in a
Module, but will execute the command: Text_Box.Text = Range("A1").Text. But
if I write a routine that resides in a Module, this same command results in
an Object Qualifier error. Is it possible to goto a subroutine in another
worksheet or Module. I think its is, I just dont know enough to figure out
how - yet!

"Dave Peterson" wrote:

This is on a userform?

I put a combobox and a textbox on a userform. I used this code:

Option Explicit
Private Sub ComboBox1_Change()
Me.TextBox1.Value = Worksheets("sheet1").Range("a1").Text
End Sub

Private Sub UserForm_Initialize()
Dim iCtr As Long
For iCtr = 1 To 10
Me.ComboBox1.AddItem "asdf" & iCtr
Next iCtr
End Sub

====
You may also want to consider using a label--instead of a textbox.


cincode5 wrote:

Hello,

I would like to use a VBA Text Box to display different sets of messages
that can be invoked from various other VBA sub routines. For example, if
someone uses a Pull Down menu to select a User ID, I would llike to use the
Pull Down's Sub Routine to assign a message using Text_Box.Text =
Range("???##").Text.

I don't know if this is the best way to change the contents of a Text Box,
but if someone out there more familiar with VBA can help me to understand the
correct procedure for accomplishing this, I would be greatful for the insight.

--
Regards...


--

Dave Peterson

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

So your textbox is on a worksheet. And you created the textbox using the
control toolbox toolbar?

If yes, you can get the value of that textbox by just qualifying where the
textbox is:

MsgBox Worksheets("sheet1").TextBox1.Value 'or .Text

If the textbox is from the Drawing toolbar (but still on a worksheet), you can
do:

MsgBox Worksheets("sheet1").TextBoxes("text box 2").Text

And you can plop the value into the textboxes, too.

'Control toolbox toolbar version
Worksheets("sheet1").TextBox1.Text = ActiveSheet.Range("A1").Text

'Drawing toolbar version
Worksheets("sheet1").TextBoxes("text box 2").Text _
= ActiveSheet.Range("A1").Text

cincode5 wrote:

Thanks Dave... You seem to be bailing me out of delimmas more frequently.

I'm slowly coming to understand VBA, and when I wrote this post I was
stiffled by what I believe is a sharing issue between Modules and code that
resides in worksheet subroutines. The subroutine for the textbox is not in a
Module, but will execute the command: Text_Box.Text = Range("A1").Text. But
if I write a routine that resides in a Module, this same command results in
an Object Qualifier error. Is it possible to goto a subroutine in another
worksheet or Module. I think its is, I just dont know enough to figure out
how - yet!

"Dave Peterson" wrote:

This is on a userform?

I put a combobox and a textbox on a userform. I used this code:

Option Explicit
Private Sub ComboBox1_Change()
Me.TextBox1.Value = Worksheets("sheet1").Range("a1").Text
End Sub

Private Sub UserForm_Initialize()
Dim iCtr As Long
For iCtr = 1 To 10
Me.ComboBox1.AddItem "asdf" & iCtr
Next iCtr
End Sub

====
You may also want to consider using a label--instead of a textbox.


cincode5 wrote:

Hello,

I would like to use a VBA Text Box to display different sets of messages
that can be invoked from various other VBA sub routines. For example, if
someone uses a Pull Down menu to select a User ID, I would llike to use the
Pull Down's Sub Routine to assign a message using Text_Box.Text =
Range("???##").Text.

I don't know if this is the best way to change the contents of a Text Box,
but if someone out there more familiar with VBA can help me to understand the
correct procedure for accomplishing this, I would be greatful for the insight.

--
Regards...


--

Dave Peterson


--

Dave Peterson
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
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM
Hide text that doesn't fit in the cell Rene Excel Discussion (Misc queries) 1 December 16th 04 04:34 PM
Moving text from one cell to another. estaban botas Excel Worksheet Functions 1 December 15th 04 02:04 PM
how to hyperlink text to a cell steve New Users to Excel 1 December 14th 04 08:21 PM
Macro or Function to make text size to suite text Length? lbbss Excel Discussion (Misc queries) 4 December 14th 04 07:53 PM


All times are GMT +1. The time now is 07:39 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"