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 Next row based on Cell Value

Can anyone please help?

I am currently repeating the following VBA code several hunderd times and
change the Range and Rows values manually.

Application.ScreenUpdating = False
If Range("C5").Value = "" Then
Rows("6:6").EntireRow.Hidden = True
ElseIf Range("C5").Value < "" Then
Rows("6:6").EntireRow.Hidden = False
End If

Application.ScreenUpdating = False
If Range("C6").Value = "" Then
Rows("7:7").EntireRow.Hidden = True
ElseIf Range("C6").Value < "" Then
Rows("7:7").EntireRow.Hidden = False
End If

Application.ScreenUpdating = False
If Range("C7").Value = "" Then
Rows("8:8").EntireRow.Hidden = True
ElseIf Range("C7").Value < "" Then
Rows("8:8").EntireRow.Hidden = False
End If

Application.ScreenUpdating = False
If Range("C8").Value = "" Then
Rows("9:9").EntireRow.Hidden = True
ElseIf Range("C8").Value < "" Then
Rows("9:9").EntireRow.Hidden = False
End If

Application.ScreenUpdating = False
If Range("C9").Value = "" Then
Rows("10:10").EntireRow.Hidden = True
ElseIf Range("C9").Value < "" Then
Rows("10:10").EntireRow.Hidden = False
End If


as you can imagine this is very labor intensive.

I believe that there should be an easier way of doing this, can you please
help?

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Hide Next row based on Cell Value

Hi,

you could use Excel's AdvancedFilter to show only the rows when there is
data in Column C.

If you haven't used AdvancedFilter (in a long time), look he
http://www.contextures.com/xladvfilter01.html

and concerning your problem, especially he
http://www.contextures.com/xladvfilter02.html#Blank

Of course, you can start the AdvancedFilter via VBA...

Regards,
xlDominik.


VS182501 schrieb:
Can anyone please help?

I am currently repeating the following VBA code several hunderd times and
change the Range and Rows values manually.

Application.ScreenUpdating = False
If Range("C5").Value = "" Then
Rows("6:6").EntireRow.Hidden = True
ElseIf Range("C5").Value < "" Then
Rows("6:6").EntireRow.Hidden = False
End If

Application.ScreenUpdating = False
If Range("C6").Value = "" Then
Rows("7:7").EntireRow.Hidden = True
ElseIf Range("C6").Value < "" Then
Rows("7:7").EntireRow.Hidden = False
End If

Application.ScreenUpdating = False
If Range("C7").Value = "" Then
Rows("8:8").EntireRow.Hidden = True
ElseIf Range("C7").Value < "" Then
Rows("8:8").EntireRow.Hidden = False
End If

Application.ScreenUpdating = False
If Range("C8").Value = "" Then
Rows("9:9").EntireRow.Hidden = True
ElseIf Range("C8").Value < "" Then
Rows("9:9").EntireRow.Hidden = False
End If

Application.ScreenUpdating = False
If Range("C9").Value = "" Then
Rows("10:10").EntireRow.Hidden = True
ElseIf Range("C9").Value < "" Then
Rows("10:10").EntireRow.Hidden = False
End If


as you can imagine this is very labor intensive.

I believe that there should be an easier way of doing this, can you please
help?

Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Hide Next row based on Cell Value

Use a loop.The below works from 5 to 100

Dim lngRow As Long

Application.ScreenUpdating = False
For lngRow = 5 To 100
If Range("C" & lngRow).Value = "" Then
Rows(lngRow + 1).Hidden = True
Else
Rows(lngRow + 1).Hidden = False
End If
Next
Application.ScreenUpdating = False

--
If this post helps click Yes
---------------
Jacob Skaria


"VS182501" wrote:

Can anyone please help?

I am currently repeating the following VBA code several hunderd times and
change the Range and Rows values manually.

Application.ScreenUpdating = False
If Range("C5").Value = "" Then
Rows("6:6").EntireRow.Hidden = True
ElseIf Range("C5").Value < "" Then
Rows("6:6").EntireRow.Hidden = False
End If

Application.ScreenUpdating = False
If Range("C6").Value = "" Then
Rows("7:7").EntireRow.Hidden = True
ElseIf Range("C6").Value < "" Then
Rows("7:7").EntireRow.Hidden = False
End If

Application.ScreenUpdating = False
If Range("C7").Value = "" Then
Rows("8:8").EntireRow.Hidden = True
ElseIf Range("C7").Value < "" Then
Rows("8:8").EntireRow.Hidden = False
End If

Application.ScreenUpdating = False
If Range("C8").Value = "" Then
Rows("9:9").EntireRow.Hidden = True
ElseIf Range("C8").Value < "" Then
Rows("9:9").EntireRow.Hidden = False
End If

Application.ScreenUpdating = False
If Range("C9").Value = "" Then
Rows("10:10").EntireRow.Hidden = True
ElseIf Range("C9").Value < "" Then
Rows("10:10").EntireRow.Hidden = False
End If


as you can imagine this is very labor intensive.

I believe that there should be an easier way of doing this, can you please
help?

Thanks in advance.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Hide Next row based on Cell Value

If you want VBA instead of AdvancedFilter, no loop necessary:

With Range("C5:C100")
..Rows.Hidden=False ' Show all
..SpecialCells(xlCellTypeBlanks).EntireRow.Hidden= true ' hide rows when
cell is blank
End With


Regards,
Dominik.



Jacob Skaria schrieb:
Use a loop.The below works from 5 to 100

Dim lngRow As Long

Application.ScreenUpdating = False
For lngRow = 5 To 100
If Range("C" & lngRow).Value = "" Then
Rows(lngRow + 1).Hidden = True
Else
Rows(lngRow + 1).Hidden = False
End If
Next
Application.ScreenUpdating = False

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
hide row based on cell value jat Excel Worksheet Functions 2 February 19th 10 09:05 PM
Hide row based on cell value Munchkin Excel Worksheet Functions 2 June 25th 09 02:21 AM
Hide Rows based on value of a cell Gordon[_2_] Excel Programming 2 September 25th 08 01:10 PM
Is there a way to HIDE a row based on a value of a cell ? Reddiance Excel Discussion (Misc queries) 4 January 26th 05 02:57 AM
Hide Row Based on cell value GaryF Excel Programming 3 April 27th 04 04:55 PM


All times are GMT +1. The time now is 06:29 PM.

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

About Us

"It's about Microsoft Excel"