Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Populate TextBox with Change Event

I have a form with two textboxes. TextBox1 is the row # that contains
specific data in that row in column B that I would like to appear in
TextBox2. So, everytime I change TextBox1 I would like TextBox2 to change.
I need help writing the change event code to select the range with the
variable row number in TextBox1.

For example, if I change TextBox1 to "3", TextBox2 should populate with data
that's located in Range B3 from the sheet.

Thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Populate TextBox with Change Event

Here is one way:

Private Sub TextBox1_Change()
Dim myTxt As String
myTxt = Me.TextBox1.Text
If Me.TextBox1.Text < "" And IsNumeric(myTxt) Then
Me.TextBox2.Text = ActiveSheet.Range("B" & myTxt).Value
End If
End Sub

Copy code to UserForm code module


"Johnny" wrote in message
...
I have a form with two textboxes. TextBox1 is the row # that contains
specific data in that row in column B that I would like to appear in
TextBox2. So, everytime I change TextBox1 I would like TextBox2 to
change.
I need help writing the change event code to select the range with the
variable row number in TextBox1.

For example, if I change TextBox1 to "3", TextBox2 should populate with
data
that's located in Range B3 from the sheet.

Thank you



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Populate TextBox with Change Event

Try,

Private Sub TextBox1_Change()
On Error Resume Next
Me.TextBox2.Text = Cells(TextBox1, "B").Text
End Sub

Hope this helps, if so click "YES" below.
--
Cheers,
Ryan


"Johnny" wrote:

I have a form with two textboxes. TextBox1 is the row # that contains
specific data in that row in column B that I would like to appear in
TextBox2. So, everytime I change TextBox1 I would like TextBox2 to change.
I need help writing the change event code to select the range with the
variable row number in TextBox1.

For example, if I change TextBox1 to "3", TextBox2 should populate with data
that's located in Range B3 from the sheet.

Thank you

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Populate TextBox with Change Event

That worked perfectly. Thank you very much. I have a follow up question I
hope you can help me with as well unless you think I need to do a separte
post. Anyway, I would like to export the TextBox2 data into another tab on
the spreadsheet called "Report" in cell B14. However I would like to add the
data (which is text) to the end of the text that is already in that cell so
that I do not delete what is already there.

I appreciate your help!

"Ryan H" wrote:

Try,

Private Sub TextBox1_Change()
On Error Resume Next
Me.TextBox2.Text = Cells(TextBox1, "B").Text
End Sub

Hope this helps, if so click "YES" below.
--
Cheers,
Ryan


"Johnny" wrote:

I have a form with two textboxes. TextBox1 is the row # that contains
specific data in that row in column B that I would like to appear in
TextBox2. So, everytime I change TextBox1 I would like TextBox2 to change.
I need help writing the change event code to select the range with the
variable row number in TextBox1.

For example, if I change TextBox1 to "3", TextBox2 should populate with data
that's located in Range B3 from the sheet.

Thank you

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Populate TextBox with Change Event

Sure that is easy. Set up a quick new post, that would be great and I'll
have it for you.
--
Cheers,
Ryan


"Johnny" wrote:

That worked perfectly. Thank you very much. I have a follow up question I
hope you can help me with as well unless you think I need to do a separte
post. Anyway, I would like to export the TextBox2 data into another tab on
the spreadsheet called "Report" in cell B14. However I would like to add the
data (which is text) to the end of the text that is already in that cell so
that I do not delete what is already there.

I appreciate your help!

"Ryan H" wrote:

Try,

Private Sub TextBox1_Change()
On Error Resume Next
Me.TextBox2.Text = Cells(TextBox1, "B").Text
End Sub

Hope this helps, if so click "YES" below.
--
Cheers,
Ryan


"Johnny" wrote:

I have a form with two textboxes. TextBox1 is the row # that contains
specific data in that row in column B that I would like to appear in
TextBox2. So, everytime I change TextBox1 I would like TextBox2 to change.
I need help writing the change event code to select the range with the
variable row number in TextBox1.

For example, if I change TextBox1 to "3", TextBox2 should populate with data
that's located in Range B3 from the sheet.

Thank you



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Populate TextBox with Change Event

Add this to the UserForm code module.

Private Sub TextBox2_Change()
Dim rng As Range
Set rng = Sheets("Report").Range("B14")
rng.Value = rng.Value & " " & Me.TextBox2.Text
End Sub

When you select the value for TextBox1, it will add a value to TextBox2 and
that will trigger a change which will run the above code to put TB2 value in
B14 on Report.


"Johnny" wrote in message
...
That worked perfectly. Thank you very much. I have a follow up question I
hope you can help me with as well unless you think I need to do a separte
post. Anyway, I would like to export the TextBox2 data into another tab
on
the spreadsheet called "Report" in cell B14. However I would like to add
the
data (which is text) to the end of the text that is already in that cell
so
that I do not delete what is already there.

I appreciate your help!

"Ryan H" wrote:

Try,

Private Sub TextBox1_Change()
On Error Resume Next
Me.TextBox2.Text = Cells(TextBox1, "B").Text
End Sub

Hope this helps, if so click "YES" below.
--
Cheers,
Ryan


"Johnny" wrote:

I have a form with two textboxes. TextBox1 is the row # that contains
specific data in that row in column B that I would like to appear in
TextBox2. So, everytime I change TextBox1 I would like TextBox2 to
change.
I need help writing the change event code to select the range with the
variable row number in TextBox1.

For example, if I change TextBox1 to "3", TextBox2 should populate with
data
that's located in Range B3 from the sheet.

Thank you



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
worksheet change event auto populate Nelly Excel Programming 2 March 21st 07 05:51 PM
change event; return focus to original textbox matt Excel Programming 3 February 26th 07 02:57 AM
Textbox.change event not firing! Craig M Excel Programming 0 October 3rd 06 04:30 AM
help with textbox change event N E Body Excel Programming 1 October 14th 04 10:07 PM
Textbox change event Ian Mangelsdorf Excel Programming 2 April 17th 04 09:30 AM


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