Sub CommandButton_Click()


Posted by Jim on July 28, 2001 10:12 AM

I have a CommandButton that on click performs addition
the problem is if you click it more than once it performs
the addition more than once is their a line of code that
would only allow one click while the UserForm was open?
Any ideas would be appreciated
Jim

Posted by steve w on July 28, 2001 10:16 AM

How about unloading the userform after it is clicked
Sub CommandButton_Click()
"your code"
unload userform1
end sub

Posted by Jim on July 28, 2001 10:22 AM

Steve,
That would work if i only had 1 button, but i have several and need
the UserForm to stay on the screen
Regards
Jim


Posted by Dax on July 28, 2001 10:26 AM

How about changing the Enabled property of the command buttons? For example, you could have a line of code

Commandbutton1.Enabled=False
Commandbutton2.Enabled=False
'Now carry out various calculations
Commandbutton1.Enabled=True
Commandbutton2.Enabled=True

How about that?

Regards,
Dax.


Posted by steve w on July 28, 2001 10:33 AM

Hi jim
Ok then maybe something like this
What I'm thinking is after the button is pushed you can have it chabge a cell somewhere in a worksheet to true(Lets say sheet1 cell "a1"
Then maybe try something like this

Sub CommandButton_Click()
If sheet1.range("A1")=true then
"your code"
end if
end sub

Then what you can do is on the userforn activate code have it change A1 to false.


Private Sub UserForm_Activate()
sheet1.range("A1")=false
End Sub

I have not tested this but I think it will work
let me know
steve w

Posted by steve w on July 28, 2001 10:38 AM


hi jim
Sub CommandButton1_Click()

"your code"
Commandbutton1.Enabled=False
end sub


steve w



Posted by Jim on July 28, 2001 10:54 AM

It works

Thanks, Steve you nailed It!