calling a macro from a cell formula

viper

Active Member
Joined
Feb 15, 2002
Messages
382
I have a worksheet that is hidden when activatated and asks for a password before viewing. I wanted it to ascend the cells each time is was deactivated, but couldn't get that to work so I added a command button for the user to click to ascend the cells in the event of new entries. That worked fine but now the sheet will not hide(error message saying cannot hide), is this due to the command button being added? If so is their any property adjustments I need to do to the command button so that it will hide(I'm assuming that is the reason the page doesn't hide because the button won't hide)? Or any code adjustment I need to make? As far as calling a macro, I have a cell that I have thought about using to replace the command button. If the user enters the word "ascend" into the cell it will call the macro I used for the command button. But I can't figure out how to call a macro from a cells formula. Any help?

Thanks,
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
I don't think it's the command button that's causing your sheet not to be hidden. If it's not the only sheet in the workbook then you *should* be able to hide it, but without seeing your workbook and code, I couldn't say for sure.

As for the second question, add this code to your worksheet- it'll run the procedure called 'YourMacro' anytime anyone enters 'ascend' into cell A1 (case-insensitive, change as necessary for the name of your macro and the cell you want to run it from): -

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Count > 1 Then Exit Sub
If Target.Address <> "$A$1" Then Exit Sub
If UCase(Target.Value) = "ASCEND" Then Call YourMacro

End Sub
 
Upvote 0

Forum statistics

Threads
1,213,559
Messages
6,114,302
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top