Can we tell which cell an image is on? - PLEASE HELP

  • Thread starter Thread starter kenji4861
  • Start date Start date
K

kenji4861

The user is clicking on a button that says "HIDE"
and when the user hits it.. it hides the row where the button exists.

IS THERE A WAY I CAN DO THIS?
 
Hi kenji4861,

Are you talking about an image or a CommandButton? If it's a CommandButton,
you can use code like this:

Private Sub CommandButton1_Click()
With CommandButton1.TopLeftCell.EntireRow
.Hidden = Not .Hidden
End With
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
Thanks! Getting close, this is an image.. or a picture I put in th
cell. Is there a way I can make this work still
 
It would be very similar with an image:

Sub Picture1_Click()
With Worksheets("Sheet1").Shapes("Picture 1").TopLeftCell.EntireRow
.Hidden = Not .Hidden
End With
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
This would only work if all the command buttons have the same name.

Jake said:
*Hi kenji4861,

Are you talking about an image or a CommandButton? If it's
CommandButton,
you can use code like this:

Private Sub CommandButton1_Click()
With CommandButton1.TopLeftCell.EntireRow
.Hidden = Not .Hidden
End With
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

The user is clicking on a button that says "HIDE"
and when the user hits it.. it hides the row where the butto exists.

IS THERE A WAY I CAN DO THIS?
 
Jake your code does not work.. I tried just renaming every button to
name.. but it doesn't work
 
I dropped some pictures onto a worksheet (using the icon on the Drawing
toolbar).

I assigned ALL the pictures this same macro:

Option Explicit
Sub pictureX_click()

Dim myPict As Picture
Set myPict = ActiveSheet.Pictures(Application.Caller)

myPict.TopLeftCell.EntireRow.Hidden = True

End Sub
 
Back
Top