PDA

View Full Version : Help formulation commandbutton



morteza2006
12-03-2012, 03:41 AM
Hi all
I need help
I have a userform and a command button
I want cell a1 on sheet 1 in any order that I open the userform and press the command button to run the command
Example
If I wrote the following formula in cell a1
sub commandbutton1_click ()
msgbox "aaa"
end sub
After opening the userform and clicks the commandbutton to run this command.
And if I have the following formula in cell a1
sub commandbutton1_click ()
userform1.height = 100
end sub
After opening the userform and clicks the commandbutton to run this command.
Thank you

taps
12-04-2012, 01:56 AM
Hi,
Could you please explain once again what is the purpose of userform and the command button?

Regards
taps

morteza2006
12-04-2012, 02:23 AM
Example :

taps
12-05-2012, 01:50 AM
Hi,

Create a Data Validation List in A1 cell and put all required actions there. Such as..
"Msgbox aaa"
Userform1.Height = 100

etc..

and then put codes in a command button like below..

Private Sub CommandButton1_Click()
If Range("A1").Value = "Msgbox aaa" Then
MsgBox "aaa"
ElseIf Range("A1").Value = "userform1.height = 100" Then
Userform1.Height = 100
End If
End Sub

Regards
taps

morteza2006
12-05-2012, 03:09 AM
Hi,

Create a Data Validation List in A1 cell and put all required actions there. Such as..
"Msgbox aaa"
Userform1.Height = 100

etc..

and then put codes in a command button like below..

Private Sub CommandButton1_Click()
If Range("A1").Value = "Msgbox aaa" Then
MsgBox "aaa"
ElseIf Range("A1").Value = "userform1.height = 100" Then
Userform1.Height = 100
End If
End Sub

Regards
taps
Hello to you
My dear friend, your answer is correct
But I do not want code written in Visual Basic in Excel
In cell a1 I have written code that is written in Visual Basic.
Sorry, you can not just tell the story