+ Reply to Thread
Results 1 to 29 of 29

Reference an image in a changing worksheet

  1. #1
    Registered User
    Join Date
    10-19-2021
    Location
    Surfside Beach, TX
    MS-Off Ver
    365
    Posts
    16

    Reference an image in a changing worksheet

    I have limited skills but looking for assistance solving a problem without outside programming like VBA, macros etc.

    I have a spreadsheet where the entries are calculated from a root seed. I want to be able to reference an image from another sheet based upon the value. I have found several sources on the web but there is one essential missing link. The starting cell for the reference varies from sheet to sheet. Example: I have a monthly calendar (which I can produce from other sources on the web). The "seed" calculation determines the first day of the week for the viewable calendar, so the actual first day of the month can be in any of the top 7 cells. I want to be able to use that cell reference to begin populating subsequent days in the month.

    Since I am new, I can't put images in the post so I'll use some text magic:

    28 29 30 1 2 3 4 (First week of the month)
    P1 P2 P3 P4 and so on

    5 6 7 8 9 10 11
    P5 P6 P7 P8 P9 P10 P11

    The next month will probably start on another day of the week but Day1 and Image 1 need to be paired. I'm sure it can be done by programming in some language but I'm just curious enough to want to do this within the workbook but not motivated enough (or even capable enough) to figure it out.
    Thanks for any assistance.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Reference an image in a changing worksheet

    Hi, welcome to the forum.
    I suggest you correct the Office version in your profile; I don't 2109 is here yet, shouldn't it be 2019
    Even if you're new, you can attach a sample file, make sure it doesn't contain private or sensitive data.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    10-19-2021
    Location
    Surfside Beach, TX
    MS-Off Ver
    365
    Posts
    16

    Re: Reference an image in a changing worksheet

    I AM FROM THE FUTURE AND I HAVE COME TO.....
    Actually, that is the version that is shown in the account settings. Don't know what to tell you. It is Office 365 Complete packsage.
    I'll upload a sample as soon as I remove the propritary references.
    Last edited by graybeardtx; 10-24-2021 at 06:24 PM.

  4. #4
    Registered User
    Join Date
    10-19-2021
    Location
    Surfside Beach, TX
    MS-Off Ver
    365
    Posts
    16

    Re: Reference an image in a changing worksheet

    Here is a sample file. The initial page is for June 2021 and the 4 day images are correctly placed. However changing the month to July (Via drop-down in the Month field) and Day 1 remains in the same block but Day1 1 of the calendar shifts to the fifth column.
    )
    Attached Files Attached Files

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Reference an image in a changing worksheet

    Hi FUTURE GUY
    Will take a look and get back to you

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Reference an image in a changing worksheet

    I don't know if others can do it with formulas but I can with macros, is that an option for you?
    For your profile: Ms-Off Ver: = 365 (2109 is the MS internal version number) and the build is extra information
    Last edited by Keebellah; 10-25-2021 at 03:10 AM. Reason: type-oooo

  7. #7
    Registered User
    Join Date
    10-19-2021
    Location
    Surfside Beach, TX
    MS-Off Ver
    365
    Posts
    16

    Re: Reference an image in a changing worksheet

    Updated the version to 365 - just shows you how much of a rookie I am.
    I was sure it could be done with a macro. Macros looks like a foreign language and I don't really want to learn another language at my age (assuming I could still learn). I am not too proud to take any assistance provided. I can generally hack existing code - just unable to create.

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Reference an image in a changing worksheet

    Never too old for new tricks, I'm still learning and almost 73 . . .
    Macros are just a set of sequential instructions that carry out exactly what its told to do with If and Else and otherwise, you can go on for ages.
    You will have to structure the file and meet some basic rules but it can be done.
    You've got coloured squares for each Day, will this always be such or other images?
    Will you be updating the Day1 for the next month or are these static images?

  9. #9
    Registered User
    Join Date
    10-19-2021
    Location
    Surfside Beach, TX
    MS-Off Ver
    365
    Posts
    16

    Re: Reference an image in a changing worksheet

    The images are static. Cell placement is the variable. For example the Day1 image will always be on the first day of the month.
    A little clarification if it is not obvious - The day of the mmonth and the image are in separate rows in the same column. i.e. Day 1 is in C3 and the image is in C4.

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Reference an image in a changing worksheet

    That's all clear, my question was when a new month is displayed the Day 1 image in the list of days is still the same as the Day 1 image of the previous month or will you change them as the month changes? THAT is/was my question

  11. #11
    Registered User
    Join Date
    10-19-2021
    Location
    Surfside Beach, TX
    MS-Off Ver
    365
    Posts
    16

    Re: Reference an image in a changing worksheet

    Let me see if I understand your question and answer accordingly. The Day1 image will always be the same image (initially but let's solve this one first). Here are some images to demonstrate 2 different months:
    Attachment 753146Attachment 753147

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Reference an image in a changing worksheet

    Attachments non useable, link is invalid, attach image as you would a file

  13. #13
    Registered User
    Join Date
    10-19-2021
    Location
    Surfside Beach, TX
    MS-Off Ver
    365
    Posts
    16

    Re: Reference an image in a changing worksheet

    The "Attach a File" icon brings up the screen to choose the file and the "file reference is what is attached. I haven't found any other way to attach a file. I'll keep looking but until then the text equivalent will have to do. SOrry about all the ,, and __ - it was necessary to maintaining the integrity of the image.

    Month 1: S __ M___ T___ W___ Th___ F___ S
    ,,,,,,,,,,,,,,,,,,,,,,,,, I1 ___I2___ I3___ I4


    Month 2: S __ M___ T___ W___ Th___ F___ S
    ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,I1___ I2___ I3
    ,,,,,,,,,,,,,I4
    Last edited by graybeardtx; 10-26-2021 at 07:57 PM.

  14. #14
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Reference an image in a changing worksheet

    If you read the attached PDF you'll see how you can attach different file types, it's also in the forum's explanations
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    10-19-2021
    Location
    Surfside Beach, TX
    MS-Off Ver
    365
    Posts
    16

    Re: Reference an image in a changing worksheet

    Simple as all Microsoft products
    Attached Images Attached Images

  16. #16
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Reference an image in a changing worksheet

    Okay, got it

  17. #17
    Registered User
    Join Date
    10-19-2021
    Location
    Surfside Beach, TX
    MS-Off Ver
    365
    Posts
    16

    Re: Reference an image in a changing worksheet

    I have finally made some progress. By using the Macro Record function I was able to decipher a "stanza" that performs the function of placing the image on the calendar page. I have cut and pasted several copies of the "stanzas" and manually updated the sheet position and the image to place there. I am now trying to figure out how to make the code so that it loops and places the images. The goal now is to figure out how to do that in VB. It would be simpler if the first of each month always began on a Sunday . So we'll see how long that takes making the start date variable.
    Attached Files Attached Files
    Last edited by graybeardtx; 11-20-2021 at 10:28 AM. Reason: add exampple

  18. #18
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Reference an image in a changing worksheet

    I would say, great job, but have you noticed what happens if you run the same macro again?
    You still haven't answered my question bout if the pictures are going to be the same for each month or if it's just Day 1 Day 2 etc.
    And what happens when a new month starts?

  19. #19
    Registered User
    Join Date
    10-19-2021
    Location
    Surfside Beach, TX
    MS-Off Ver
    365
    Posts
    16

    Re: Reference an image in a changing worksheet

    I must say that I haven't' I presume it would fail horribly. I always clear the data and restart the macro. I am thinking about making sure the macro gets run just once.
    The pictures are keyed to the days of the month, the beginning date is the fly in the ointment. Each month rarely starts on the same day
    so the first "picture", which is always paired for Day 1 through Day 30..31, etc. is placed in the cell where the Day# is calculated.

  20. #20
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Reference an image in a changing worksheet

    I understand the calendar and that DAY 1 is not always a Monday or a Sunday etc.
    What I mean is the list of images for each day (you now have 4 with the caption Day 1, Day 2
    Will this always be the same picture but only placing Day 1 in the block for Day 1, the Day 2 until Day 30 or 31 or 28 or 29 in case of February?

  21. #21
    Registered User
    Join Date
    10-19-2021
    Location
    Surfside Beach, TX
    MS-Off Ver
    365
    Posts
    16

    Re: Reference an image in a changing worksheet

    You are correct. There are 31 unique pictures representing each day. The pictures are static and the image will not change , just the location of the image based upon t he day.

  22. #22
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Reference an image in a changing worksheet

    Clear, I can work with that

  23. #23
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Reference an image in a changing worksheet

    This seems to work, there is however one thing.
    All the day images in the PayMnt worksheet must be named correctly, not the caption, the actual image name.
    Syntax must be Day space day number so Day 1, Day 2, Day 3, Day 10 etc.
    The Month selection is still the same dropdown list you had except that I added two columns to the named range and named the new named range allmonths
    Column A the month name, Column B the month number and Column C the calculated date for the calendar's A2 cell value

    There is also a named range allyears with starts with the actual date's year - 3 and ends with actual date's year + 3 so you have a calendar choice now from 2018 through 24

    If you select another month or another year the calendar refreshes the images
    Attached Files Attached Files

  24. #24
    Registered User
    Join Date
    10-19-2021
    Location
    Surfside Beach, TX
    MS-Off Ver
    365
    Posts
    16

    Re: Reference an image in a changing worksheet

    Thanks for the sample solution. It appears to accomplish the function I envisioned. I will now study the programming to learn more about the techniques.
    Programming logic is hard for me to accomplish. I'll try to update the sample to use the real data.

  25. #25
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Reference an image in a changing worksheet

    I excuse myself for not placing comments in the VBA code.
    My logic and programming techniques are my own, what I mean to say is that there are probably many ways to do this and who knows which technique is the best.
    One thing, the size of the 'day' images you place in Paymnt does not really matter, the code fits it to the target cell in the calendar.

  26. #26
    Registered User
    Join Date
    10-19-2021
    Location
    Surfside Beach, TX
    MS-Off Ver
    365
    Posts
    16

    Re: Reference an image in a changing worksheet

    No excuse necessary. I learn better by deciphering code.
    The code that you made to fit the image in the target cell is wonderful. Thanks again.

  27. #27
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Reference an image in a changing worksheet

    You're welcome.
    Like I said, it's not all my code but it's put together with what I've found and done earlier with similar challenges
    Patience and time is what you need most to learn VBA

  28. #28
    Registered User
    Join Date
    10-19-2021
    Location
    Surfside Beach, TX
    MS-Off Ver
    365
    Posts
    16

    Re: Reference an image in a changing worksheet

    I have another question regarding ths program. Some of the images are overlapping the borders of adjacent cells. The resulting image has some of the cell borders overlapped with the image so there is an inconsistency in the way the objects are modified. I'm trying to decipher the code of the macro and having difficulty understanding the code snippets. At one time I thought the images were massaged to fit in the assigned space but I can't find that in the code. The variables appear to be simply assigned with out specific modifications. WHat am I missing?

  29. #29
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Reference an image in a changing worksheet

    Hi, I don't really know, like I mentioned in my post #27 it's not all my code.
    Will have to look into it.
    Don't know if you modified anything in the file I attached last year november.
    As far as I remember the image size is set to the cell size. you will have to look in that section of the vba code.
    I have included that section of code maybe changing the LockAspectRatio to msoTrue ?
    VBA is patience and perseverance
    Please Login or Register  to view this content.
    Last edited by Keebellah; 02-08-2022 at 05:06 AM.

+ 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. [SOLVED] VBA to transfer image FROM userform image control TO a worksheet cell
    By Zoediak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2014, 02:51 PM
  2. Indirect reference to changing worksheet name
    By Peanuts890 in forum Excel General
    Replies: 2
    Last Post: 05-21-2010, 09:52 AM
  3. Changing worksheet reference
    By fatpiggy123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2010, 11:37 AM
  4. Hyperlink to an image in other worksheet, displaying entire image.
    By twilliams in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-07-2006, 06:10 PM
  5. [SOLVED] Changing a Worksheet Reference Formula using a drop down box
    By DaveyC4S in forum Excel General
    Replies: 1
    Last Post: 12-09-2005, 09:10 AM
  6. [SOLVED] How to change reference to other worksheet by changing one cell?
    By Ms.Vahl in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-10-2005, 03:00 AM
  7. Replies: 0
    Last Post: 09-22-2005, 12:05 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