T
TheMilkGuy
Hi folks,
I know next to nothing about VB code, but even *I* know this is
ugly:
Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
Me.Pictures("Picture 1").Visible = True
With Range("F1")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F2")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F3")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F2
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F4")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F2
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F5")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F6")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F7")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F8")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F9")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F10")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F11")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F12")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F13")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F14")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F15")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F16")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
End Sub
Based on value (True/False) at F1. If true, an image appears.
These T/F values range from F1:F15... Could someone please simplify
this formula for me?
Thanks!
I know next to nothing about VB code, but even *I* know this is
ugly:
Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
Me.Pictures("Picture 1").Visible = True
With Range("F1")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F2")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F3")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F2
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F4")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F2
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F5")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F6")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F7")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F8")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F9")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F10")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F11")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F12")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F13")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F14")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F15")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
With Range("F16")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = F1
oPic.Left = .Left
Exit For
End If
Next oPic
End With
End Sub
Based on value (True/False) at F1. If true, an image appears.
These T/F values range from F1:F15... Could someone please simplify
this formula for me?
Thanks!