Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Hide row loop


Hello,

I am looking for a way to do this.

If any cell in row J is not blank then hide the entire row.

my current code is


Sub test()
Dim cell As Range
For Each cell In Worksheets("wshopcurrent").Range("j8:j8000")
If cell.Text < "" Then
Selection.EntireRow.Hidden = True
End If
Next
End Sub

but this seems to only hide the first one it finds and then stops.

Can anyone help please?

Thanks in advance

John


--
johncassell
------------------------------------------------------------------------
johncassell's Profile: http://www.excelforum.com/member.php...o&userid=25016
View this thread: http://www.excelforum.com/showthread...hreadid=393848

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Hide row loop

It may be because you are hiding the current Selection, which has nothing to
do with your loop variable.

Try
cell.entireRow.hidden=true.

The isEmpty(range) function is quite good for checking for blank cells as it
doesn't throw up any errors.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Hide row loop

Hello John
Amend
Selection.EntireRow.Hidden = True

To
Cell.EntireRow.Hidden = True

HTH
Cordially
Pascal

"johncassell" a
écrit dans le message de
...

Hello,

I am looking for a way to do this.

If any cell in row J is not blank then hide the entire row.

my current code is


Sub test()
Dim cell As Range
For Each cell In Worksheets("wshopcurrent").Range("j8:j8000")
If cell.Text < "" Then
Selection.EntireRow.Hidden = True
End If
Next
End Sub

but this seems to only hide the first one it finds and then stops.

Can anyone help please?

Thanks in advance

John


--
johncassell
------------------------------------------------------------------------
johncassell's Profile:

http://www.excelforum.com/member.php...o&userid=25016
View this thread: http://www.excelforum.com/showthread...hreadid=393848



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default Hide row loop

Sub test()
Dim cell As Range
For Each cell In Worksheets("wshopcurrent").Range("j8:j8000")
If cell.Text < "" Then
cell.EntireRow.Hidden = True
End If
Next
End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Hide row loop


That worked a treat, Thanks very much for your help people. Muc
appreciated and thanks for replying in the first place.

Joh

--
johncassel
-----------------------------------------------------------------------
johncassell's Profile: http://www.excelforum.com/member.php...fo&userid=2501
View this thread: http://www.excelforum.com/showthread.php?threadid=39384

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Slow VBA code....Hide/Unhide Loop Tami Excel Worksheet Functions 2 August 4th 09 01:53 AM
Want to Hide columns in spreadsheet but NOT hide data in chart. KrispyData Charts and Charting in Excel 1 March 20th 09 04:45 PM
Loop Function unable to loop Junior728 Excel Programming 1 July 28th 05 10:23 AM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 04:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"