PDA

View Full Version : Solved: Which column is the calling button (mostly) in?



Asterix
08-06-2008, 12:15 AM
Dear all, I'd like to place buttons in many cells within the title row of a spreadsheet in order to, for example, sort the column that the button is in.

Can I reliably detect which column a button is in (as well as allowing me to resolve instances where the button is split over 2 columns)?

mdmackillop
08-06-2008, 12:23 AM
MsgBox ActiveSheet.Shapes(Application.Caller).TopLeftCell.Address

Asterix
08-06-2008, 12:46 AM
ta

Aussiebear
08-06-2008, 02:22 AM
Hi Asterix, if MD's solution has fixed this issue, can you kindly mark the thread as solved by using the thread tools option?

Thankyou.

Asterix
08-06-2008, 02:53 AM
Aah, but in testing have found that this...


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

...resolves to a type mismatch. Is the problem with the code or the way I've applied the code.

Bob Phillips
08-06-2008, 03:18 AM
Perhaps this what you need then



MsgBox Me.CommandButton1.TopLeftCell.Column

Asterix
08-06-2008, 03:25 AM
Now that works xld. Thankyou.