ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   loop hide cells (https://www.excelbanter.com/excel-programming/429797-loop-hide-cells.html)

DarrenL

loop hide cells
 
I tried this yesterday and got answers which, unfortunately, did not satisfy
my need. Thank you for your help, though. Let me try and explain a little
better.
I am trying to create a loop, where as many rows as I want will hide if, for
example, column b in the row above is empty. this is my code for one line.
Dim rng As Range
Set rng = Me.Range("b142:b186")
If Not Intersect(rng, Target) Is Nothing Then
Rows(143).EntireRow.Hidden = IsEmpty(rng.Value)
End If
I am thinking that I need a variable and a +1 or a -1 for each row, but can
not come up with anything. Anyone?
Thanks again for your help yesterday.
Darren

Patrick Molloy

loop hide cells
 
i thought that I'd replied.beg pardon...
try this:

dim cell as range
for each cell in range("B142:B186").Cells
if cell.Value = "" then Rows(Cell.row).EntireRow.Hidden = True
next

"DarrenL" wrote in message
...
I tried this yesterday and got answers which, unfortunately, did not
satisfy
my need. Thank you for your help, though. Let me try and explain a
little
better.
I am trying to create a loop, where as many rows as I want will hide if,
for
example, column b in the row above is empty. this is my code for one line.
Dim rng As Range
Set rng = Me.Range("b142:b186")
If Not Intersect(rng, Target) Is Nothing Then
Rows(143).EntireRow.Hidden = IsEmpty(rng.Value)
End If
I am thinking that I need a variable and a +1 or a -1 for each row, but
can
not come up with anything. Anyone?
Thanks again for your help yesterday.
Darren



DarrenL

loop hide cells
 
That's kind of what I have, except I need it to hide a row below the cell
that I am referencing......any thoughts?

"Patrick Molloy" wrote:

i thought that I'd replied.beg pardon...
try this:

dim cell as range
for each cell in range("B142:B186").Cells
if cell.Value = "" then Rows(Cell.row).EntireRow.Hidden = True
next

"DarrenL" wrote in message
...
I tried this yesterday and got answers which, unfortunately, did not
satisfy
my need. Thank you for your help, though. Let me try and explain a
little
better.
I am trying to create a loop, where as many rows as I want will hide if,
for
example, column b in the row above is empty. this is my code for one line.
Dim rng As Range
Set rng = Me.Range("b142:b186")
If Not Intersect(rng, Target) Is Nothing Then
Rows(143).EntireRow.Hidden = IsEmpty(rng.Value)
End If
I am thinking that I need a variable and a +1 or a -1 for each row, but
can
not come up with anything. Anyone?
Thanks again for your help yesterday.
Darren



Don Guillett

loop hide cells
 
??
for each cell in range("B142:B186")
if cell= "" then Rows(Cell.row+1).Hidden = True
next

or

for i=186 to 142
if cells(i,"b")="" then rows(i+1).hidden=true
next i

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"DarrenL" wrote in message
...
That's kind of what I have, except I need it to hide a row below the cell
that I am referencing......any thoughts?

"Patrick Molloy" wrote:

i thought that I'd replied.beg pardon...
try this:

dim cell as range
for each cell in range("B142:B186").Cells
if cell.Value = "" then Rows(Cell.row).EntireRow.Hidden = True
next

"DarrenL" wrote in message
...
I tried this yesterday and got answers which, unfortunately, did not
satisfy
my need. Thank you for your help, though. Let me try and explain a
little
better.
I am trying to create a loop, where as many rows as I want will hide
if,
for
example, column b in the row above is empty. this is my code for one
line.
Dim rng As Range
Set rng = Me.Range("b142:b186")
If Not Intersect(rng, Target) Is Nothing Then
Rows(143).EntireRow.Hidden = IsEmpty(rng.Value)
End If
I am thinking that I need a variable and a +1 or a -1 for each row, but
can
not come up with anything. Anyone?
Thanks again for your help yesterday.
Darren




A possible solution

loop hide cells
 
Well, in that case it seems to me that this line should do the trick:

if cell.Value = "" then Rows(Cell.row+1).EntireRow.Hidden = True


"DarrenL" wrote:

That's kind of what I have, except I need it to hide a row below the cell
that I am referencing......any thoughts?

"Patrick Molloy" wrote:

i thought that I'd replied.beg pardon...
try this:

dim cell as range
for each cell in range("B142:B186").Cells
if cell.Value = "" then Rows(Cell.row).EntireRow.Hidden = True
next

"DarrenL" wrote in message
...
I tried this yesterday and got answers which, unfortunately, did not
satisfy
my need. Thank you for your help, though. Let me try and explain a
little
better.
I am trying to create a loop, where as many rows as I want will hide if,
for
example, column b in the row above is empty. this is my code for one line.
Dim rng As Range
Set rng = Me.Range("b142:b186")
If Not Intersect(rng, Target) Is Nothing Then
Rows(143).EntireRow.Hidden = IsEmpty(rng.Value)
End If
I am thinking that I need a variable and a +1 or a -1 for each row, but
can
not come up with anything. Anyone?
Thanks again for your help yesterday.
Darren




All times are GMT +1. The time now is 08:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com