Thread: excel and fun?
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Ken Johnson Ken Johnson is offline
external usenet poster
 
Posts: 1,073
Default excel and fun?

Hi Lisa,

1. Compile error: Invalid outside procedure...


sounds like you have copied and pasted too much.

Make sure when you copy the code that you start at...

Public Sub ScrollStatus()

and finish at...

End Sub

If you copy anything above "Public Sub ScrollStatus()" or below "End
Sub" you will get the error message you mentioned.
I suspect you have copied and pasted...

For I = 1 To 3000
DoEvents
Next I

make the 3000 larger to slow the scrolling or smaller to speed up.


which appears above "Public Sub ScrollStatus()" and this has caused
the error. So just delete those lines and it should work.

2. There is no change in smiley when I change the value in the target cell.

Plus.. can the target cell have a calculation in it (i.e.
=IF(B290,IF(B29=B31,"YES","NO"),"")


The code I supplied assumed the target value would be a number.
Looking at your formula I'm guessing you would want the Happy face to
appear when the formula returns "YES", Sad face to appear when the
formula returns "NO" and neither face when "" is the returned value.

If I'm correct then try...

Private Sub Worksheet_Calculate()
Dim rgTarget As Range
Set rgTarget = Range("A1")
'change A1 to suit your situation.
'Change A1 to the address of the cell
'with the formula...
'=IF(B290,IF(B29=B31,"YES","NO"),"")
With rgTarget
Me.Shapes("Happy").Visible = .Value = "YES"
Me.Shapes("Sad").Visible = .Value = "NO"
End With
End Sub

Ken Johnson