ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Read from text field (https://www.excelbanter.com/excel-programming/364486-read-text-field.html)

april27

Read from text field
 
Hi I have a user form that opens when the workbook is opened. In this user
form I have text fields in which the user shall submitt info. How do I get my
macro to "read" the text submitted into the text field after a button on the
user form is pressed?

Bernie Deitrick

Read from text field
 
You do that by reading the text or caption property of the objects on the
userform. The specific code depends on your setup, but in general something
like this in the commandbutton click event, with myVar1,2 &3 being declared
public variables...

myVar1 = Userfrom1.Textbox1.Text
myVar2 = Userfrom1.Textbox2.Text
myVar3 = Userfrom1.Textbox3.Text

HTH,
Bernie
MS Excel MVP

"april27" wrote in message
...
Hi I have a user form that opens when the workbook is opened. In this user
form I have text fields in which the user shall submitt info. How do I get
my
macro to "read" the text submitted into the text field after a button on
the
user form is pressed?




Tom Ogilvy

Read from text field
 
Just access the value of the control:

msgbox Userform1.Textbox1.Value



--
Regards,
Tom Ogilvy


"april27" wrote:

Hi I have a user form that opens when the workbook is opened. In this user
form I have text fields in which the user shall submitt info. How do I get my
macro to "read" the text submitted into the text field after a button on the
user form is pressed?



All times are GMT +1. The time now is 04:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com