Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
mariat
 
Posts: n/a
Default Macro Button Question

Heya All,

I am trying to insert and delete rows using macros. Ive assigned the
Macro to a button, but would like to be able to insert (and delete)
exactly where the button is on the worksheet, no matter where the
activecell is..

So, I guess my question is, is it possible to get the cell reference
behind a graphic button?

Or, even better, assign a macro to a cell?

ta,
Maria

  #2   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben
 
Posts: n/a
Default Macro Button Question

Maria

There are "insert row" and "insert column" buttons available from
ToolsCustomizeCommandsInsert

Also "delete row" and "delete column" buttons available from
ToolsCustomizeCommandsEdit

Back to your questions...........

How would the button move around the sheet even if you can find out its
position?

AFAIK you can only return the position of the button, not any cell reference
because a button floats and is not attached to a cell.

To have a macro run from a cell you could have Worksheet_BeforeDoubleClick
event code in your worksheet.


Gord Dibben Excel MVP

On 30 Nov 2005 13:04:11 -0800, "mariat" wrote:

Heya All,

I am trying to insert and delete rows using macros. Ive assigned the
Macro to a button, but would like to be able to insert (and delete)
exactly where the button is on the worksheet, no matter where the
activecell is..

So, I guess my question is, is it possible to get the cell reference
behind a graphic button?

Or, even better, assign a macro to a cell?

ta,
Maria


  #3   Report Post  
Posted to microsoft.public.excel.misc
Zack Barresse
 
Posts: n/a
Default Macro Button Question

mariat,

If you are wanting to delete where the button is residing, wouldn't that
delete the button too? Doesn't make much sense to me.. but I have been know
to be slow to catch on.. ;)


Gorb,

Not sure why you can't return any cell reference. If we're using an object
from the Shapes collection, we can make use of the TopLeftCell property and
the Application.Caller...

Sub ShowMe()
MsgBox ActiveSheet.Shapes(Application.Caller).TopLeftCell .Address
End Sub

We can even make use of the BottomRightCell property if it spans more than
one cell to get the entire range that it occupies...

Sub ShowMeMore()
Dim strTop As String
Dim strBottom As String
strTop = ActiveSheet.Shapes(Application.Caller).TopLeftCell .Address
strBottom =
ActiveSheet.Shapes(Application.Caller).BottomRight Cell.Address
Range(Range(strTop), Range(strBottom)).Select
MsgBox Range(Range(strTop), Range(strBottom)).Address & " selected!"
End Sub

The Shapes collection may not reside "inside" of a cell along with values,
but it does have an association with it which we can use. It is in this
sense that I consider a shapes button 'attached' to a cell.

--
Regards,
Zack Barresse, aka firefytr, (GT = TFS FF Zack)
To email, remove the NO SPAM. Please keep correspondence to the board, as
to benefit others.


"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
Maria

There are "insert row" and "insert column" buttons available from
ToolsCustomizeCommandsInsert

Also "delete row" and "delete column" buttons available from
ToolsCustomizeCommandsEdit

Back to your questions...........

How would the button move around the sheet even if you can find out its
position?

AFAIK you can only return the position of the button, not any cell
reference
because a button floats and is not attached to a cell.

To have a macro run from a cell you could have Worksheet_BeforeDoubleClick
event code in your worksheet.


Gord Dibben Excel MVP

On 30 Nov 2005 13:04:11 -0800, "mariat" wrote:

Heya All,

I am trying to insert and delete rows using macros. Ive assigned the
Macro to a button, but would like to be able to insert (and delete)
exactly where the button is on the worksheet, no matter where the
activecell is..

So, I guess my question is, is it possible to get the cell reference
behind a graphic button?

Or, even better, assign a macro to a cell?

ta,
Maria




  #4   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben
 
Posts: n/a
Default Macro Button Question

Thanks Zack

I'll copy this to module and experiment with it.

Looks good.


Gord

On Wed, 30 Nov 2005 16:30:43 -0800, "Zack Barresse"
wrote:

mariat,

If you are wanting to delete where the button is residing, wouldn't that
delete the button too? Doesn't make much sense to me.. but I have been know
to be slow to catch on.. ;)


Gorb,

Not sure why you can't return any cell reference. If we're using an object
from the Shapes collection, we can make use of the TopLeftCell property and
the Application.Caller...

Sub ShowMe()
MsgBox ActiveSheet.Shapes(Application.Caller).TopLeftCell .Address
End Sub

We can even make use of the BottomRightCell property if it spans more than
one cell to get the entire range that it occupies...

Sub ShowMeMore()
Dim strTop As String
Dim strBottom As String
strTop = ActiveSheet.Shapes(Application.Caller).TopLeftCell .Address
strBottom =
ActiveSheet.Shapes(Application.Caller).BottomRigh tCell.Address
Range(Range(strTop), Range(strBottom)).Select
MsgBox Range(Range(strTop), Range(strBottom)).Address & " selected!"
End Sub

The Shapes collection may not reside "inside" of a cell along with values,
but it does have an association with it which we can use. It is in this
sense that I consider a shapes button 'attached' to a cell.


  #5   Report Post  
Posted to microsoft.public.excel.misc
mariat
 
Posts: n/a
Default Macro Button Question

Hey,

There is an Insert and a Delete button on each row.. does that make
sense - i will also try what you posted too.. thanks..

ta,
maria

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Assign a macro to Command Button Object dallin Excel Discussion (Misc queries) 2 July 13th 05 03:50 AM
Macro Button Maggie Excel Discussion (Misc queries) 3 June 28th 05 04:29 AM
How do I Assign Macro to a button? BellExcel Charts and Charting in Excel 4 May 20th 05 07:21 PM
Attaching a macro to a VB button on a form WildGlio Excel Worksheet Functions 2 March 25th 05 11:11 PM


All times are GMT +1. The time now is 02:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"