Home > Software design >  Get the value of a clicked cell
Get the value of a clicked cell

Time:06-17

In my Excel Worksheet I have a cell with an Image of a folder. When clicked I start a macro that ask for the folder selection. That part works fine but I would like to write the folder path in the cell next to the image. My problem is that when the user clicks on the image the cell selection isn't changed. So there is no way to know the location ActiveCell.Address and choose the .Next to go next to it. Is there a way to actually get where the user clicked even if the selection doens't change ?

Thank you.

CodePudding user response:

Try this:

With ThisWorkbook.Sheets("Sheet1")
        buttonName = .Shapes(Application.Caller).name
        row = .Shapes(buttonName).TopLeftCell.row
        col = .Shapes(buttonName).TopLeftCell.col
End With

Dim cell As Range
cell = ActiveSheet.Cells(row, col)
cell.Offset(1, 0).Value = 'your_folder_path_here'
  • Related