Mac VBA & Excel, auto change image based on a cell
Closed
winstoncheets
Posts
12
Registration date
Thursday June 7, 2018
Status
Member
Last seen
June 9, 2018
-
Jun 7, 2018 at 03:21 PM
winstoncheets Posts 12 Registration date Thursday June 7, 2018 Status Member Last seen June 9, 2018 - Jun 9, 2018 at 03:15 PM
winstoncheets Posts 12 Registration date Thursday June 7, 2018 Status Member Last seen June 9, 2018 - Jun 9, 2018 at 03:15 PM
Related:
- Dia symbol in excel
- At symbol in keyboard - Guide
- Underscore symbol in keyboard - Guide
- Tick symbol in word - Guide
- Pipe symbol mac - Guide
- Number to words in excel - Guide
7 responses
Do this....
Change the path to the absolute path, and not the relative!
Use:
"C:\Users\"
If your username is not "danielcheetham", you need to got to "C:\Users\" and figure out who you are logged in as!
Understand, this is not even close to portable, and don't try it outside of the machine you built it on!
Change the path to the absolute path, and not the relative!
Use:
"C:\Users\"
If your username is not "danielcheetham", you need to got to "C:\Users\" and figure out who you are logged in as!
Understand, this is not even close to portable, and don't try it outside of the machine you built it on!
winstoncheets
Posts
12
Registration date
Thursday June 7, 2018
Status
Member
Last seen
June 9, 2018
Jun 8, 2018 at 01:09 AM
Jun 8, 2018 at 01:09 AM
Yes, sorry the path should read "/Users/dc/Desktop/pictures" in both cases, which is the absolute path. Working on a MacBook you don't have a C: drive but I am working on the machine that it was built on.
So, lets assume the code is correct at this point, ok? Please show us in your sheet how you are deploying it. Give us an example of the code in usage on the sheet!
Didn't find the answer you are looking for?
Ask a question
It works for me... see example:
In the above example I was not certain if the image would stretch to the RANGE, so I put a large range on it. It seems that the range can be a single cell, so deployment of:
will produce the same result as the posted example!
This is all I changed:
See example of how to deploy it!
It's kind of fun to do the impossible! -Walter Elias Disney
In the above example I was not certain if the image would stretch to the RANGE, so I put a large range on it. It seems that the range can be a single cell, so deployment of:
=picturelookup("eagleBadge",E2,1)
will produce the same result as the posted example!
This is all I changed:
("C:\Users\User\Desktop\" & Value & ".png", msoFalse, msoTrue, picLeft, picTop, -1, -1)
--
See example of how to deploy it!
It's kind of fun to do the impossible! -Walter Elias Disney
Here is another example of taking it just one more step, looking up the PNG value in a cell. The below example shows the same code changing the image based on the value in cell A1.
Please remember, this code only looks for PNG files, and if you are using a JPG, it is wrong. You could always just include the file format in the name, and drop the PNG from the static code, if you need the flexibility! See below!
Please remember, this code only looks for PNG files, and if you are using a JPG, it is wrong. You could always just include the file format in the name, and drop the PNG from the static code, if you need the flexibility! See below!
winstoncheets
Posts
12
Registration date
Thursday June 7, 2018
Status
Member
Last seen
June 9, 2018
Jun 8, 2018 at 03:19 PM
Jun 8, 2018 at 03:19 PM
Hi ac3mark,
I created a eagleBadge.png in the pictures folder just so we are working off the same sheet.
I tried deploying it in the View Macros button on the Developer tab and got the error message as below
I tried entering it into the spreadsheet cell A1 and nothing happened,
I'm wandering if it is because Mac OS doesn't have the ActiveX controls..? And if so whether the VBA code could be adapted to use Form Controls instead?
...and thanks for getting involved in the troubleshooting
I created a eagleBadge.png in the pictures folder just so we are working off the same sheet.
I tried deploying it in the View Macros button on the Developer tab and got the error message as below
I tried entering it into the spreadsheet cell A1 and nothing happened,
I'm wandering if it is because Mac OS doesn't have the ActiveX controls..? And if so whether the VBA code could be adapted to use Form Controls instead?
...and thanks for getting involved in the troubleshooting
OK, in the VBA developer explorer, add in a new MODULE and place the code into that module, not on the worksheet. As so...
If you placed the code onto the sheet itself, it needs to be cut from the sheet in the explorer, and added to the new module.
When you begin a new formula, and you start with "=pictur", does the line predictively finish with picturelookup? If not, then it is not in the correct location (module!). The worksheet should see it as a native formula, and try to predict what you want.
If you placed the code onto the sheet itself, it needs to be cut from the sheet in the explorer, and added to the new module.
When you begin a new formula, and you start with "=pictur", does the line predictively finish with picturelookup? If not, then it is not in the correct location (module!). The worksheet should see it as a native formula, and try to predict what you want.
winstoncheets
Posts
12
Registration date
Thursday June 7, 2018
Status
Member
Last seen
June 9, 2018
Jun 8, 2018 at 04:35 PM
Jun 8, 2018 at 04:35 PM
winstoncheets
Posts
12
Registration date
Thursday June 7, 2018
Status
Member
Last seen
June 9, 2018
Jun 8, 2018 at 05:08 PM
Jun 8, 2018 at 05:08 PM
winstoncheets
Posts
12
Registration date
Thursday June 7, 2018
Status
Member
Last seen
June 9, 2018
Jun 8, 2018 at 05:09 PM
Jun 8, 2018 at 05:09 PM
any thoughts on whether it may be the ActiveX controls?
Ok try this. Make a very simple script. Something like....
function ItFired()
msgbox("Hello World")
end function
And call it....with:
In Cell B1 place: =IF(A1="fire",ItFired())
In Cell A1 place "fire", without quotes!
That way we are trying to determine if it is the firing of the code, or the picture stuff!
function ItFired()
msgbox("Hello World")
end function
And call it....with:
In Cell B1 place: =IF(A1="fire",ItFired())
In Cell A1 place "fire", without quotes!
That way we are trying to determine if it is the firing of the code, or the picture stuff!