Variable not found


Posted by Adrae on December 06, 2001 12:40 PM

I am trying to run the falling and am getting the error "compile error: variable not found" on the i
Any ideas why? Thanks :-)

Sub HideRows()
On Error Resume Next
With Range("Q10:R8121")
.EntireRow.Hidden = False
For i = 1 To .Rows.Count
If WorksheetFunction.Sum(.Rows(i)) = 0 Then
.Rows(i).EntireRow.Hidden = True
End If
Next i
End With
End Sub

Posted by Tom Urtis on December 06, 2001 1:01 PM

Your modules may require variables if you have selected "Require Variable Declaration" in the Code Settings section on the Editor tab from the Tools > Options menu in the VBE. Deselect that box and the code should work.

It is usually a good idea to have that box selected though, and simply declare your variables with each procedure.

Tom Urtis

Posted by Adrae on December 06, 2001 1:16 PM

Thanks so much for your help and patience. I deselected the declare variable option but I continue to get the below mentioned error. How can I go ahead and declare this variable? Thanks again :-)

Posted by Tom Urtis on December 06, 2001 1:36 PM

I'm not sure if this is the answer, but if "Option Explicit" appears at the head of your module, then delete that line. Again, this is not the best way to go about solving this sort of problem, but it would work in this case. If you do not see Option Explicit, then I am out of ideas for now.

Tom U. Thanks so much for your help and patience. I deselected the declare variable option but I continue to get the below mentioned error. How can I go ahead and declare this variable? Thanks again :-)



Posted by Adrae Nunez on December 06, 2001 1:41 PM

I used a Dim command and that worked for hiding two columns containing intergers totaling 0.

How can this be modified to do the following:

If Q=0 AND D="" Then hide the entire row

column Q contains integers & D contains strings so I would need to be able to work in a dim to make the variable names different for each column.

Any ideas? Thanks :-)