Can I include a picture in a formula i.e. if cell a26 >90% then s.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can I include a picture in a formula i.e. if cell a26 >90% then show picture
x, if less then show picture y?...
 
I can't figure out how to insert the pictures? HELP. I can modify the
PicTable on sheet 2 to expand the name range but I haven't been successful in
loading the pictures.
 
JE's routine assumes that the pictures are already on the worksheet.

So load your pictures manually (or anyway you know), then use JE's code to
hide/show the ones you want.
 
Maybe you can just check the name and then do nothing for that name:

Option Explicit

Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("F1")
For Each oPic In Me.Pictures
If oPic.Name = "Nameofpicturethatshouldnotchange" Then
'do nothing
Else
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
End If
Next oPic
End With
End Sub
 
Hi Dave,

I tried the following as below, but its ends up with a compile error.
Thanks for trying.

Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("E30")
For Each oPic In Me.Pictures
If oPic.Name = "Picture 1" Then
'do nothing
Else
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
Next oPic
End With
End Sub
 
You dropped an "End If" line near the bottom.

I'm not sure if your code is indented (or if just the message was not), but
indenting can make finding errors like this easier to find. And it would help
others if you indicated the line that was marked as an error and what that error
is, too.

Option Explicit
Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("E30")
For Each oPic In Me.Pictures
If oPic.Name = "Picture 1" Then
'do nothing
Else
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
End If '<--- Added
Next oPic
End With
End Sub



Hi Dave,

I tried the following as below, but its ends up with a compile error.
Thanks for trying.

Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("E30")
For Each oPic In Me.Pictures
If oPic.Name = "Picture 1" Then
'do nothing
Else
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
Next oPic
End With
End Sub
 
Hi Dave,

Thank you, sorry about that, I don't dive into the VB editor very often so
it doesn't stick in the grey cells.

Thanks again for your help and quick response.
 
You can change the fill color for those grey cells.

Select that range
format|cells|Pattern tab|Choose no color

<vvbg>


Hi Dave,

Thank you, sorry about that, I don't dive into the VB editor very often so
it doesn't stick in the grey cells.

Thanks again for your help and quick response.
 
Dave Peterson said:
Maybe you can just check the name and then do nothing for that name:

Option Explicit

Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("F1")
For Each oPic In Me.Pictures
If oPic.Name = "Nameofpicturethatshouldnotchange" Then
'do nothing
Else
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
End If
Next oPic
End With
End Sub
 
I am trying to do the same thing as the other gentleman but apparently I am
missing something. I have entered what you have below but my logo "Picture
1" keeps disappearing everytime I use the other event (I have it inserting a
signature upon a person's name).

***Please help!
 
Did you change the name of the picture in the code?
I am trying to do the same thing as the other gentleman but apparently I am
missing something. I have entered what you have below but my logo "Picture
1" keeps disappearing everytime I use the other event (I have it inserting a
signature upon a person's name).

***Please help!
 
Yes, I changed the code to read "Picture 1" and then I inserted the picture
where I needed it in the file and named it Picture 1. But then when I test
by changed the signature event it deletes the picture 1.
 
Here is my code:


Option Explicit

Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("A66")
For Each oPic In Me.Pictures
If oPic.Name = "Picture 1" Then
'do nothing
Else
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
End If '
Next oPic
End With
End Sub


chrstrcy said:
Yes, I changed the code to read "Picture 1" and then I inserted the picture
where I needed it in the file and named it Picture 1. But then when I test
by changed the signature event it deletes the picture 1.
 
So you want to see "Picture 1" all the time?

Option Explicit
Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False 'this hides all the pictures
With me.Range("A66")
For Each oPic In Me.Pictures
If lcase(oPic.Name) = lcase("Picture 1") Then
'show it
oPic.visible = true
Else
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
End If '
Next oPic
End With
End Sub
 
Yes, and I want it to show in cell A1 - does this need to be noted in the
code as well?? I will try what you have below. Thank you for your help.
 
Nope. The code will use the name--not the location.

Did it work when you tried it?
Yes, and I want it to show in cell A1 - does this need to be noted in the
code as well?? I will try what you have below. Thank you for your help.
 
Back
Top