Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Trefor
 
Posts: n/a
Default Can I get Button name or Cell Reference

If I have a sheet with 20 buttons (1 on each row) and each button points to
the same macro, is it possible for the macro to determine the Row number (Or
possibly the Button Name)?

Based on the row, the macro will continue updating data on that Row.
--
Trefor
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default Can I get Button name or Cell Reference

This is a button from the Forms toolbar?

Option Explicit
Sub testme()

Dim BTN As Button

Set BTN = ActiveSheet.Buttons(Application.Caller)

MsgBox Application.Caller & vbLf _
& BTN.Name & vbLf _
& BTN.TopLeftCell.Address(0, 0) & vbLf _
& BTN.Caption

End Sub


Application.caller will give you the name of the button.
(BTN.Name is redundant--but sometimes easier to type <bg.)


Trefor wrote:

If I have a sheet with 20 buttons (1 on each row) and each button points to
the same macro, is it possible for the macro to determine the Row number (Or
possibly the Button Name)?

Based on the row, the macro will continue updating data on that Row.
--
Trefor


--

Dave Peterson
  #3   Report Post  
Ken Johnson
 
Posts: n/a
Default Can I get Button name or Cell Reference


Trefor,
If it's a button on a worksheet from the forms toolbar then
Application.Caller returns the button's name. If you want to identify
the button using its caption eg "Start" then try:
Dim WhichButton as Shape
Set WhichButton = ActiveSheet.Shapes(Application.Caller)
If WhichButton.TextFrame.Characters.Text = "Start" then do something..
Other than that I really don't know. I mainly work on a Mac so I know
nothing about ActiveX controls.
Hope this isn useful.
Ken Johnson

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
How do I leave formula cell blank if 2nd reference cell is empty? Liana S Excel Discussion (Misc queries) 2 October 21st 05 04:38 PM
copied formula has correct cell reference, but result of original lvito Excel Worksheet Functions 1 October 14th 05 04:37 PM
dynamic cell reference within a text string gvm Excel Worksheet Functions 4 July 25th 05 02:40 AM
Flexible Cell Reference Brandt Excel Discussion (Misc queries) 5 June 2nd 05 10:23 PM
Creating button as cell jpizzle Excel Discussion (Misc queries) 1 June 1st 05 01:22 PM


All times are GMT +1. The time now is 10:42 PM.

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"