Not sure if this is specifically a "chart" issue but it is the chart part that is causing me issues.
I have an application where I need to have an image of something where the number of the items in the image will change from 1 to 5. I made 5 images, each with a different number of objects. The first image would have one object, the second two, the third three, and so on. I change the picture image to the one I need based on a cell value. If the cell is say "one" then it displays the image with one unit, if "two" then the image with two units, etc. If I simply use a Picture for this with the images in cells and then use the Named Manager to give them names, I can reference them by using INDIRECT and the cell where the name of the image it. This works fine and there are several guides online how to do this.
What I want to add to this is to locate some textboxes on each item in the picture to display some number. I can also get this to work using VB to locate the textboxes and hide or show them as needed. If there is only one unit in the image, I don't want all five textboxes shown, just the one. Because of the images and things being in different locations, I also need to re-position the textboxes, and do this in VB. The problem is that if the Picture changes size by any amount, or something else changes with it, everything is off. Also, trying to find the location of the textboxes relative to the entire sheet, and these are on page 4 of 5 I think, is cumbersome and relative to the whole document, not relative to the page or something on the page.
What I decided to do, was use a scatter plot chart with a point for every textbox I needed, then position the point where I needed it. I would use a Picture inserted in the chart to display the image, now everything seems to stick together and is relative to the Chart. The problem is the INDIRECT function is giving me an error "This formula is missing a range reference or a defined name". Now the exact way I am doing this works fine when the Picture is outside a Chart, except the other issues with the textbox locations. There is a Named reference for each image (ex. Image_1_1, Image_1_2, Image 2_1, etc.)). There is another Named reference for the formula of the image name which is =INDIRECT(cell_location_of_image_name) (Ex. Image_Name). What does work in the Chart is if I reference the image name directly. With the example names I gave using =Image_1_1 will display that image in the Picture. However, using either the Named reference (In this example =Image_Name) or =INDIRECT(cell_location_of_image_name) directly, does not work and throws up an error. The error when using INDIRECT is "This formula is missing a range reference or a defined name" and the error when I use the Name reference is "Reference isn't valid". So it is able to change the image if I type in the Named reference name of the image directly but not using the other methods, which allows it to be dynamic.
I am trying to keep as much of this out of VB since I am doing this for other people to use and they won't understand how it works. I would rather not have to change the image in VB, but can if I have to. I am just wondering why it works fine when the Picture is not in the Chart but gives an error when it is in a Chart.
I am using Excel 2019.
Bookmarks