Hide when cell value (x) is < 1 but -1
On Mon, 8 Oct 2007 05:43:02 -0700, Craig147
wrote:
That is such a massive help thank you,
I just have a couple of queries
1) If i wanted to apply the same rule to columns B and D should I just copy
the IF formula and change to column numbers?
Yes.
Note that the column numbers are related to the AOI range. "1" is always the
first column in the AOI range which, if AOI does not start in Column A, may be
a different column.
2) The macro doesn't run when i press run it is only activated once i press
enter/return key after inputting one of the values in the table, is there any
way around this?
The macro was written as a worksheet change event, so only triggers on a
worksheet change.
If you want to run it optionally, as in Run Macro, then, instead of entering it
as a worksheet event, put it into a regular module (and DELETE it from the
worksheet module).
To enter it into a regular module, when you are in the "View Code" area, from
the top menu bar of the VBEditor select Insert/Module and paste the code below
into the window that opens.
Again, be sure to delete it from the worksheet module.
Modify the name and enter as follows:
================================================== ========
Option Explicit
Sub Hide()
Dim aoi As Range
Dim rw As Range
Set aoi = Range("a1:c5")
For Each rw In aoi.Rows
If rw.Columns(1) -1 And _
rw.Columns(1) < 1 And _
IsNumeric(rw.Columns(1)) = True And _
Len(rw.Columns(1).Text) 0 And _
rw.Columns(3) -1 And _
rw.Columns(3) < 1 And _
IsNumeric(rw.Columns(3)) = True And _
Len(rw.Columns(3).Text) 0 Then
rw.EntireRow.Hidden = True
Else
rw.EntireRow.Hidden = False
End If
Next rw
End Sub
==================================
Many thanks once again
You're welcome. Thanks for the feedback.
--ron
|