Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Entering data into two text boxes using one command button


Hi

I have the following code in a workbook:


Code:
--------------------

'takes data from cell A45 (Phase Instructions worksheet) and puts into textbox
Private Sub CreateEmail_Click()
On Error GoTo ErrHandler
Dim strText As String
For Each r In Sheets("Phase instructions").Range("A45").Rows
strText = ""
For Each c In r.Cells
strText = strText & c.Value
Next c
EmailSubject = EmailSubject & strText & vbCrLf
Next r
ExitPoint:
Exit Sub

ErrHandler:
If Err.Number = 999 Then
Resume Next
Else
MsgBox "Incorrect data for this printer, please re-enter", vbCritical, "PRINTER DATA ERROR"
Resume ExitPoint
End If
End Sub

--------------------


I would like for the button to fill another text box (called EmailBody)
at the same time, but I don't know how to get it to fill the two boxes.


Can anyone please advise me on what I need to change in the above code
to get this to work?

Thanks very much

CC


--
Charlie Chalk


------------------------------------------------------------------------
Charlie Chalk's Profile: http://www.excelforum.com/member.php...o&userid=32776
View this thread: http://www.excelforum.com/showthread...hreadid=526052

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Entering data into two text boxes using one command button

Charlie, I can see where you build your strings, strText then
EmailSubject but I cannot see where you are populating any textboxes.

The code to fill two texboxes withthe same variable would be something
like;
textbox1.value = EmailSubject
textbox2.value = EmailSubject

In your line
For Each r In Sheets("Phase instructions").Range("A45").Rows

This would only contain 1 row and therefore does not need a loop,
unless I am missing something.
Also, stepping through the code with F8
For Each c In r.Cells
shows that c contains the full value of Cells and as you have only
selected "A45" no loops are executed at all. The resultant value of
strText and then EmailSubject are the same as cell A45.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Entering data into two text boxes using one command button

EmailSubject.Text = EmailSubject & strText & vbCrLf
EmailBody.Text = "whatever"

--
Regards,
Tom Ogilvy


"Charlie Chalk" wrote:


Hi

I have the following code in a workbook:


Code:
--------------------

'takes data from cell A45 (Phase Instructions worksheet) and puts into textbox
Private Sub CreateEmail_Click()
On Error GoTo ErrHandler
Dim strText As String
For Each r In Sheets("Phase instructions").Range("A45").Rows
strText = ""
For Each c In r.Cells
strText = strText & c.Value
Next c
EmailSubject = EmailSubject & strText & vbCrLf
Next r
ExitPoint:
Exit Sub

ErrHandler:
If Err.Number = 999 Then
Resume Next
Else
MsgBox "Incorrect data for this printer, please re-enter", vbCritical, "PRINTER DATA ERROR"
Resume ExitPoint
End If
End Sub

--------------------


I would like for the button to fill another text box (called EmailBody)
at the same time, but I don't know how to get it to fill the two boxes.


Can anyone please advise me on what I need to change in the above code
to get this to work?

Thanks very much

CC


--
Charlie Chalk


------------------------------------------------------------------------
Charlie Chalk's Profile: http://www.excelforum.com/member.php...o&userid=32776
View this thread: http://www.excelforum.com/showthread...hreadid=526052


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
Align Text in Command button Wanna Learn Excel Discussion (Misc queries) 2 October 26th 08 12:22 PM
Entering Variable Text in Text Boxes...... Steve Jones Excel Discussion (Misc queries) 3 June 14th 07 02:34 PM
Command button text Steve W Excel Discussion (Misc queries) 1 May 4th 07 02:59 PM
Enable Command Button After Entering Text mikeg710 New Users to Excel 1 March 29th 07 04:12 PM
Strange behavior w/ Text, Button, & Check Boxes kswinth Excel Discussion (Misc queries) 0 June 26th 05 04:49 PM


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