Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #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.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,420
Default VBA not working - Messy.

Maybe this

Dim GraphPic As String

If Me.Range("BilSuc_Mth_L").Value Me.Range("Target_Max_L").Value
Then
GraphPic = "PicOver"
Else IF Me.Range("BilSuc_Gas_L").Value
Me.Range("Target_Min_L").Value Then
GraphPic = "PicWithin"
Else
GraphPic = "PicUnder"
End If

With Range("M5")
Set oPic = Me.Pictures(GraphPic)
oPic.Visible = True
oPic.Top = Range("M5").Top - 9.75
oPic.Left = Range("M5").Left - 3#
End With

--
__________________________________
HTH

Bob

"NPell" wrote in message
...
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.



Reply
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 06:23 AM.

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

About Us

"It's about Microsoft Excel"