LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 76
Default VBA not working - Messy.

Hello, this is my code at the moment...


Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("M5")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top - 9.75
oPic.Left = .Left - 3#
Exit For
End If
Next oPic
End With
End Sub

This works fine, with the formula in M5 being;
=IF(BilSuc_Gas_LTarget_Max_L,"PicOver",IF
(BilSuc_Gas_LTarget_Min_L,"PicWithin","PicUnder") )


Im trying to convert this to be self contained in VBA, but failing....

Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
Dim GraphPic As Integer

If BilSuc_Mth_L Target_Max_L Then
GraphPic = "PicOver"
Else IF BilSuc_Gas_LTarget_Min_L Then GraphPic = "PicWithin"
GraphPic = "PicUnder"
End If


With Range("GraphPic")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = Range("M5").Top - 9.75
oPic.Left = Range("M5").Left - 3#
Exit For
End If
Next oPic
End With
End Sub



But this does not work, any ideas?
Thanks in advance.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate working days but change working week SamB Excel Discussion (Misc queries) 1 September 1st 08 09:17 PM
Help! Messy-looking "pie chart"!!! AbbaFan Charts and Charting in Excel 2 August 20th 06 09:12 AM
Messy tab characters Gargoyl Excel Discussion (Misc queries) 2 April 19th 06 11:09 PM
Transforming messy database into clean database SteveC Excel Discussion (Misc queries) 4 January 24th 06 11:34 PM
Messy Text to Columns sweeneysmsm Excel Discussion (Misc queries) 3 November 8th 05 01:08 AM


All times are GMT +1. The time now is 11:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"