Insert picture macro based on value(s) of other cells

WombatBob

New Member
Joined
Sep 29, 2012
Messages
1
Greetings,
I have been trying to get the following macro to work with my particular requirement and have had no luck thus far. I am a macro novice and any assistance would be greatly appreciated. I am trying to insert a picture in a weight tracking spreadsheet based on the value of another cell and whether it is greater or lower than the previous days weight. For example:

DateWeightChange
Monday, July 23, 2012217.6NA
Tuesday, July 24, 2012217.40.2
Wednesday, July 25, 2012216.41.0

<tbody>
</tbody>


I have a formula in column C (Change) that tracks the difference between days - =IF(B2-B3=B2, "", B2-B3)

I also have conditional formatting in column D that changes the fill color of the cell to red if the day's weight is higher than the previous day's weight, green for lower, and yellow for the same.

I have two jpg images, one a red arrow up, the other a green arrow down, that I would like to insert in the D column on the row corresponding to the day's weight either going up or down.

The way I see it, there are two ways to format the conditional statement, either compare today's weight value (column B, Weight) to the previous day's and if it is greater, insert red, lower would be green, no change would be yellow. Or if the Change cell for the day was positive, insert green, negative would be red, no zero would be yellow.

I have located a macro that does a picture insert, but I do not understand enough about the coding of such things to modify it for my needs. I have included this macro from the site [Excel] A macro to insert pictures in hopes that it can serve as a starting place for someone more knowledgeable than me.


Sub Picture() * *
Range("A6").Select 'This is where picture will be inserted * *
Dim picname As String * *
picname = Range("B6") 'This is the picture name * *
ActiveSheet.Pictures.Insert("C:\Users\vbayat\My Documents\vidabayat\re-market\" & picname & ".jpg").Select 'Path to where pictures are stored * *
''''''''''''''''''''''''''''''''''''''''''''''''''''''' * *
' This resizes the picture * *
''''''''''''''''''''''''''''''''''''''''''''''''''''''' * *
With Selection * *
.Left = Range("A6").Left * *
.Top = Range("A6").Top * *
.ShapeRange.LockAspectRatio = msoFalse * *
.ShapeRange.Height = 100# * *
.ShapeRange.Width = 80# * *
.ShapeRange.Rotation = 0# * *
End With * *




Range("A10").Select * *
Application.ScreenUpdating = True * *




Exit Sub * *




ErrNoPhoto: * *
MsgBox "Unable to Find Photo" 'Shows message box if picture not found * *
Exit Sub * *
Range("B20").Select * *




End Sub


Again, any help or guidance that can be offered is much appreciated.Regards,-BOB
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,215,580
Messages
6,125,654
Members
449,245
Latest member
PatrickL

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top