Textbox in Userform not recognised by Module
The Modules don't recognize the controls on a Userform. There are several things you can do.
1) Put the MyMacro code in the Userform code
o
2) Pick a cell on the worksheet to pass the value to. Then pick it up from sheet in MyMacr
Private Sub txtTest_Change() Instead of this sub you could also set the ControlSource fo
range("A1") = txtTest.value the textbox in the userform to a particular cell in the worksheet
End Sub Just put A1 in the controlsource line in the properties window
Sub MyMacro(
Dim strTest as Strin
strTest = range("A1"
3) Probably the best way is to add the variable to your macro nam
This assumes MyMacro is on Module
Sub MyMacro (str
strTest = st
end su
' The code on your userform could look like thi
Private Sub cmdRun_Click(
Dim Temp as strin
Temp = txtTest.valu
If Temp < vbNullString then ' This would not let the macro to be called if the textbox was empt
Module1.MyMacro Temp ' If you add the variable to the macro name on Module1 then as soon
end if ' as you type ' Module1. ' on the userform code, you should see a window open
End Sub ' with MyMacro as a choice. Then when you add that and have Module1.MyMacr
' you should see str meaning that a value needs to be in the line. Temp wil
' pass the value to st
I hope I'm being clear for you. I'm not a programmer but I've been doing a lot with Userforms
|