Macro start cell

Peeratz

New Member
Joined
Jun 30, 2011
Messages
5
I have a simple problem, but can't seem to find the answer. I want buttons to run macros in the cells following the buttons. Macros by default run wherever you have the cursor. What code do I use to tell the macro to first place the cursor in the cell next to each button?

Thanks
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Maybe I need to explain further since there haven't been any replies...

I set up a simple spreadsheet to use as an employee schedule. For every employee, I have 7 rows (Sun thru Sat) and the hours of the day as columns. I want to have a column in front of every day to blank out any hours if a person is going to be off. I inserted a "Vacation" button to run a macro to delete the cells to the right of the button (deleting any filled in hours). My macro simply deletes the data in the cells, but if my active cell is not the first hour cell, my macro will just delete data wherever my active cell happens to be. How do I tell my macro to make the cell just to the right of the "Vacation" button the active cell before deleting the data? Right now, the only thing I know to do is make a macro for each person for each day that specifies that days cells...this means several dozen macros!
Please help, I know there is any easy answer.
 
Upvote 0
With a button from the Forms toolbar then maybe something like this

Code:
Sub Button1Click()
ActiveSheet.Buttons("Button 1").TopLeftCell.Offset(, 1).Select
End Sub
 
Upvote 0
How about passing the cell address to the macro when you call it?
Code:
[I]workbookname[/I]!'[I]macroname address[/I]'

For example:-
Code:
Book1.xls!'Macro1 F6'

Then your macro will 'know' that the button you clicked sent "F6" to it.
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,240
Members
452,898
Latest member
Capolavoro009

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