ok...let me say up front, that I don't really know what I'm doing, but
everyone has to start somewhere. This is my first non-recorded macro.
I've created the following code. It seems to do what I want (because I can
watch what it's doing), except that it doesn't seem to END. I get an out of
stack space error. I'm sure this is some obvious mistake, but it eludes me.
Anyone know what i am doing wrong?
Sub eliminate_possabilities()
Dim solutions As Range
Dim cell As Range
Dim before As Integer
before = Range(quot;BG31quot;).Value
Set solutions = ActiveSheet.Range(quot;AF3:BF29quot;)
For Each cell In solutions
If cell.Value = 1 Then
cell.Offset(0, -30).ClearContents
Else:
End If
Next cell
Call CheckForChanges
End Sub
Sub CheckForChanges()
Dim after As Integer
after = Range(quot;BG31quot;).Value
If after gt; before Then
Call eliminate_possabilities
Else:
End If
End Sub
Jonathan
You do not need the Else: statements, but your issue is that the variable
'before' is not available to the second procedure as it is declared inside
the other module. Try moving the variable to the top of the module outside
of any sub that should fix it
--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.ukquot;Jonathan Cooperquot; gt; wrote in
message ...
gt; ok...let me say up front, that I don't really know what I'm doing, but
gt; everyone has to start somewhere. This is my first non-recorded macro.
gt;
gt; I've created the following code. It seems to do what I want (because I
gt; can
gt; watch what it's doing), except that it doesn't seem to END. I get an out
gt; of
gt; stack space error. I'm sure this is some obvious mistake, but it eludes
gt; me.
gt; Anyone know what i am doing wrong?
gt;
gt; Sub eliminate_possabilities()
gt;
gt; Dim solutions As Range
gt; Dim cell As Range
gt; Dim before As Integer
gt;
gt; before = Range(quot;BG31quot;).Value
gt;
gt; Set solutions = ActiveSheet.Range(quot;AF3:BF29quot;)
gt; For Each cell In solutions
gt; If cell.Value = 1 Then
gt; cell.Offset(0, -30).ClearContents
gt; Else:
gt; End If
gt; Next cell
gt;
gt; Call CheckForChanges
gt; End Sub
gt;
gt; Sub CheckForChanges()
gt;
gt; Dim after As Integer
gt;
gt; after = Range(quot;BG31quot;).Value
gt;
gt; If after gt; before Then
gt; Call eliminate_possabilities
gt; Else:
gt; End If
gt; End Sub
- Aug 07 Thu 2008 20:45
macro not working
close
全站熱搜
留言列表
發表留言
留言列表

