Here is the scenario;
A B C D
A 50 25
B 10 9
C 0.5 6
D 0.26 -0.36
E -5 0.99
I would like to be able to hide Row D because the values in column A and C
are < 1 and > -1. Please note that row C and E should not be hidden because
in one of the columns the value is > 1 or < -1.
I would really appreciate any help thanks
Craig
Do you want the row Hidden (e.g. zero height), or do you want the data
invisible?
If the latter, you can do it with conditional formatting.
Select A1
Format/Conditional Formatting
Formula Is: =AND($A1>-1,$A1<1,$C1>-1,$C1<1)
Format/Font and set the Font Color to the same as your background color.
If you actually want to Hide the rows, then you will need to use a VBA event
macro:
Right click on the sheet tab and select View Code.
Enter the code below into the window that opens:
==========================================
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
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 _
rw.Columns(3) < 1 And _
rw.Columns(3) > -1 Then
rw.EntireRow.Hidden = True
Else
rw.EntireRow.Hidden = False
End If
Next rw
End Sub
=================================
Note that, the way it displayed on my computer, Row A (or Row 1) would also be
hidden as the entries appear to be in columns B and D, leaving columns A and C
blank.
If you also want to evaluate that there be an actual entry in the cell, and
that non-numeric entries do not get evaluated, then change the code to:
==================================
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
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
========================================
--ron