+ Reply to Thread
Results 1 to 5 of 5

Function to change image on userform if clicked.

  1. #1
    Registered User
    Join Date
    08-22-2014
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    81

    Function to change image on userform if clicked.

    Hi everyone,

    im not really sure how to explain in the correct manner what i need to acheive but im sure someone will understand what im trying to do and will have a solution.

    So here goes. Im building a userform where a person enters where damage is on a mobile phone.

    I have a userform, with a drop down box it has options like, "Scratch, Dent, Cracked, Chipped, Other" in it.

    if you can imagine there would be an image of a mobile phone on the userform, overlayed on it would be a lot of cells, to acheive this i would put on top of the image, a lot of image tools, to build a grid that is transparent.
    when you click on one of the images i need the image in the now transpartent cell to change image.

    clicking on the image and chaging its image based on whats in the dropdown box is the key part. now obviously i could just do this with a IF THEN ELSE statement. If dropdown box = Dent them image1.picture = "dentimage.jpj"...

    but i would have roughly 150 images (cells) to do this for and thats a lot of coding, i also need to do a back side of the phone, so a total of 300 images (cells).

    i was thinking to make this so much quicker, pass the currently clicked image control to a function, determine whats in the dropdown box, then update the current image properties with the correct image.

    The problem i have is i dont know how to pass an object on a userform to another function to preform actions on it while in the function.

    also when you click on an image to change its picture, i need to update a cell on a spread sheet as well with the scratch, dent, etc. so the Sheet in excel can be printed with a grid of cells that is 10 columns by 15 rows, to give me the 150 cells representing the phone and where the damage on the phone is located.

    Would greatly appreciate your ideas and help with this.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Function to change image on userform if clicked.

    You can easily pass the image control to a function.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    08-22-2014
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    81

    Re: Function to change image on userform if clicked.

    Hi Norie i think you have help me before actually

    what do i need to write in the Private sub of the image_mouosedown event to pass over to the function?

    Regards

  4. #4
    Registered User
    Join Date
    08-22-2014
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    81

    Re: Function to change image on userform if clicked.

    Oh wait i worked it out

  5. #5
    Registered User
    Join Date
    08-22-2014
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    81

    Re: Function to change image on userform if clicked.

    Thank you so much Norie

    i even worked out that if i name my image control A1 and just use the control name and the Sheets(Sheet1).Range(IMAGECONTROLNAME).Value so that i dont have to change the code for all 300 image boxes. and my A1 cell on my sheet will update with the type of name as defined in the fuction

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to change the backColor of a UserForm control when/after it is clicked / updated
    By levraininjaneer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-18-2018, 02:42 AM
  2. [SOLVED] Change color of an image when clicked
    By Tpleme in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-14-2017, 08:24 PM
  3. [SOLVED] Change colour of a cell when it's clicked, change when it's clicked again.
    By Crispy85 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-16-2014, 01:10 PM
  4. [SOLVED] Load web image when cell holding URL is clicked/double-clicked
    By jchamber00 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-20-2013, 09:13 PM
  5. [SOLVED] change range a table appears every time a button within a userform is clicked
    By mcdermott2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-11-2013, 05:07 PM
  6. [SOLVED] UserForm Command Button - how to make it change appearance when clicked
    By schmidt62 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-12-2012, 10:53 AM
  7. Change image in UserForm
    By Joseph in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-19-2006, 11:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1