Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I have a protected worksheet that has a button that I want to execute using VBA. The worksheet in question is protected with the exception of certain cells where I can paste values. I am creating a VBA to do all the pasting but I can't figure out how to execute the button. Run or Call don't work. Help. TIA. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If the button is from the Forms toolbar, then just rightclick on that button and
assign your macro to it. If the commandbutton is from the Control toolbox toolbar, just double click on that commandbutton and put your code in that window. (you'll have to be in design mode for that, though.) wrote: I have a protected worksheet that has a button that I want to execute using VBA. The worksheet in question is protected with the exception of certain cells where I can paste values. I am creating a VBA to do all the pasting but I can't figure out how to execute the button. Run or Call don't work. Help. TIA. -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you are trying to fake a button click, rather than Dave's suggestion of
code location, you have a couple of options: 1 - Calling the code for the click event; Call cmdButton_Click But you will have change the _Click routine from Private (default) to Public so it can be seen outside the module. Also reference the correct WB/WS as required. 2 - Some people feel it is wrong to call events like the above. If so use cmdButton.Value=True NickHK wrote in message oups.com... I have a protected worksheet that has a button that I want to execute using VBA. The worksheet in question is protected with the exception of certain cells where I can paste values. I am creating a VBA to do all the pasting but I can't figure out how to execute the button. Run or Call don't work. Help. TIA. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Yes, I am trying to fake a button click. The worksheet (there are many worksheets, otherwise I would just click the button myself) is protected so I can't change the code. How do I go about doing #2? Would that fake a click? Thanks. NickHK wrote: If you are trying to fake a button click, rather than Dave's suggestion of code location, you have a couple of options: 1 - Calling the code for the click event; Call cmdButton_Click But you will have change the _Click routine from Private (default) to Public so it can be seen outside the module. Also reference the correct WB/WS as required. 2 - Some people feel it is wrong to call events like the above. If so use cmdButton.Value=True NickHK wrote in message oups.com... I have a protected worksheet that has a button that I want to execute using VBA. The worksheet in question is protected with the exception of certain cells where I can paste values. I am creating a VBA to do all the pasting but I can't figure out how to execute the button. Run or Call don't work. Help. TIA. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here's one way
ThisWorkbook.Worksheets("Sheet3").CommandButton4.V alue = True NickHK wrote in message ups.com... Yes, I am trying to fake a button click. The worksheet (there are many worksheets, otherwise I would just click the button myself) is protected so I can't change the code. How do I go about doing #2? Would that fake a click? Thanks. NickHK wrote: If you are trying to fake a button click, rather than Dave's suggestion of code location, you have a couple of options: 1 - Calling the code for the click event; Call cmdButton_Click But you will have change the _Click routine from Private (default) to Public so it can be seen outside the module. Also reference the correct WB/WS as required. 2 - Some people feel it is wrong to call events like the above. If so use cmdButton.Value=True NickHK wrote in message oups.com... I have a protected worksheet that has a button that I want to execute using VBA. The worksheet in question is protected with the exception of certain cells where I can paste values. I am creating a VBA to do all the pasting but I can't figure out how to execute the button. Run or Call don't work. Help. TIA. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This works perfectly.
Thanks! NickHK wrote: Here's one way ThisWorkbook.Worksheets("Sheet3").CommandButton4.V alue = True NickHK wrote in message ups.com... Yes, I am trying to fake a button click. The worksheet (there are many worksheets, otherwise I would just click the button myself) is protected so I can't change the code. How do I go about doing #2? Would that fake a click? Thanks. NickHK wrote: If you are trying to fake a button click, rather than Dave's suggestion of code location, you have a couple of options: 1 - Calling the code for the click event; Call cmdButton_Click But you will have change the _Click routine from Private (default) to Public so it can be seen outside the module. Also reference the correct WB/WS as required. 2 - Some people feel it is wrong to call events like the above. If so use cmdButton.Value=True NickHK wrote in message oups.com... I have a protected worksheet that has a button that I want to execute using VBA. The worksheet in question is protected with the exception of certain cells where I can paste values. I am creating a VBA to do all the pasting but I can't figure out how to execute the button. Run or Call don't work. Help. TIA. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Command button to toggle worksheet event code on / off? | Excel Discussion (Misc queries) | |||
c# code to add button control to the worksheet!!!! | Excel Programming | |||
How to make a button VBA code reference other VBA code subroutines??? | Excel Programming | |||
Create a newworksheet with VBA code and put VBA code in the new worksheet module | Excel Programming | |||
print different worksheet by pressing visible button on worksheet | Excel Worksheet Functions |