-
add button in excel
i need to use a visual basic program wich add a button in a excel and its script.
I know to insert the button :
ActiveSheet.OLEObjects.Add (classType:="Forms.CommandButton.1", Link:=False _
, DisplayAsIcon:=False, Left:=izq, Top:=alto, Width:=60, Height:= _
20.75).Select
i need to know insert the script
sub command1_click()
end sub
i dont know how?
thx
-
in between the
sub command1_click()
and
end sub
type your script. I cant really make sense of what your asking so that is the only answer i can give. What are you trying to achieve
-
i need insert code of commandbutton using visual basic program,
i'll open the work with the program the excel and i'll insert the button , but i don't know how insert the script of this button.
-
i need insert code of commandbutton using visual basic program,
i'll open excel with the program and i'll insert the button , but i don't know how insert the script of this button.
-
if its a macro youve created and assigned to abutton the code should already be there. Visual basic doesnt magiacally add code for you, so you will have to type it in using a keyboard
-
i think the best way is not to creat the button but to hide it.
I had the same problem, and in that case i used some code like
if i need the button then commandbutton1.left = 42
(i can see the button on my form)
if i don't need the button then commandbutton1.left = 600
(the button is not located on my form, i can't see it and reach it)
like this you don't have to generate a new button with a new code each time you create a button
you can also change the size of the userform using
userform1.width or
userform1.height