I have a userform on an Excel file called "userform":
Private Sub add1_Change()
End Sub
Private Sub add2_Change()
End Sub
Private Sub Calc_Click()
Result.Value = Val(add1.Value) + Val(add2.Value)
End Sub
This userform takes the value from the user and adds them together and shows the result in a textbox.
I want to create a new macro in another workbook named "input". The macro in this workbook should open the userform workbook, enter values in the textbox add1 and add2, then run the userform calculate button.
What I've tried thus far:
- Set
add1.valueto extract a value from say, cell A1, and similarly foradd2.value. - Then I created a macro on the input workbook to change the values in cells A1 and A2.
The problem from here is I don't know how to open the userform and click calculate.
Ideally, I would like a macro which opens the userform, enters the data and hits calculate then closes the userform - Rather than editing the userform itself.
Public Sub getUF(a): Set a = UserForm1: End Subin the wb with the userform, allows to catch that object directly... simply rungetUF MyUFVariableand then useMyUFVariableexactly the same way like you would with the userform... - Dirk ReichelWorksheet, do a calculation and then place it somewhere? What else does yourUserFormdo to not want to change now to a pure VBA code option instead of unneededUserForm's - DragonSamu