Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9206599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:12:36+00:00 2026-06-18T00:12:36+00:00

In excel, I can assign a macro to an image, with this dialog: This

  • 0

In excel, I can assign a macro to an image, with this dialog:

enter image description here

This results in the code:

Private Sub MyShape_Click()
    ' ...
End Sub

However, I will need to assign this macro to many different images. How can I determine which image was selected from inside my click handler, and how do I get a reference to it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:12:37+00:00Added an answer on June 18, 2026 at 12:12 am

    UPDATE:

    Assign the same macro to all your pictures and use Application.Caller in your macro to determine the picture/shape that called it. In this case (picture/shape) Application.Caller will be of type String.

    Private Sub GenericPicture_Click()
        Select Case Application.Caller
            Case "Picture 1"
                'do your work
                MsgBox "You got me"
            Case "Picture 2" 
                'do your work
            ...
    
        End Select 
    
        'Lets flip the picture that has been clicked
        With ActiveSheet.Shapes(Application.Caller)
            .Flip msoFlipHorizontal
        End With
    End Sub
    

    And you might also implement required behavior calling a sub, which implements needed processing logic, with a parameter from separate macros:

    Sub Picture1_Click()
        DoWork 1
    End Sub
    
    Sub Picture2_Click()
        DoWork 2
    End Sub
    
    Sub DoWork(ByVal pic As Integer)
        'Implement your logic here
        MsgBox "Hi! I am picture" & pic
    End Sub
    

    Where Picture1_Click() and Picture2_Click() are macros that you assign to your images/shapes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In an Excel formula you can use =ISERR(A1) or =ISERROR(A1) In a VBA macro
I want to know if PHPExcel can: Create Excel spreadsheets with embeded image. The
In VBA / VB.NET you can assign Excel range values to an array for
Can anyone tell me what I a doing wrong with this code? I am
Using Application.OnKey <key>, <procedure> , I can cause Excel to run <procedure> whenever <key>
How can I read excel data (office 2007 xlsx) in PHP? Is there any
Can I read an excel file without using any module? I tried like just
How can I save data from an Excel sheet to .RData file in R?
I can't open an Excel spread sheet with .NET on an x64 server using
How can I convert an Excel date (in a number format) to a proper

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.