Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default If or Case help - Which to use

I'm trying to say from rows 31 thru 1000, if U and V are zero then hide the
row. if not both zero then show the row.

Having problems putting this into an if statment wondering if I'd be better
served using a case statement but not sure how to write it.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default If or Case help - Which to use

Something like this...

Dim rng As Range
Dim rngToSearch As Range

With Application
..Calculation = xlCalculationManual
..ScreenUpdating = False
End With
Set rngToSearch = Range("U31:U1000")
rngToSearch.EntireRow.Hidden = False

For Each rng In rngToSearch
If rng.Value = 0 And rng.Offset(0, 1).Value = 0 Then _
rng.EntireRow.Hidden = True
Next rng

With Application
..Calculation = xlCalculationAutomatic
..ScreenUpdating = True
End With

--
HTH...

Jim Thomlinson


"Stephen" wrote:

I'm trying to say from rows 31 thru 1000, if U and V are zero then hide the
row. if not both zero then show the row.

Having problems putting this into an if statment wondering if I'd be better
served using a case statement but not sure how to write it.

  #3   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 207
Default If or Case help - Which to use

Stephen

Either should work; but, since you really only have two options (hide
or not hide), I would go with a simple if statement.

Something like:

Unhide all the rows,t hen run this.

Sub test()

For i = 31 To 1000
If Application.And(Cells(i, 21) = 0, Cells(i, 22) = 0) Then
Rows(i).Hidden = True
End If
Next i

End Sub

should work for you.

Good luck.

Ken
Norfolk, Va






On Dec 10, 12:32 pm, Stephen
wrote:
I'm trying to say from rows 31 thru 1000, if U and V are zero then hide the
row. if not both zero then show the row.

Having problems putting this into an if statment wondering if I'd be better
served using a case statement but not sure how to write it.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default If or Case help - Which to use

The If is simple:

Sub stephen()
For i = 31 To 1000
If Cells(i, "U").Value = 0 And Cells(i, "V").Value = 0 Then
Cells(i, "U").EntireRow.Hidden = True
End If
Next
End Sub

--
Gary''s Student - gsnu200761


"Stephen" wrote:

I'm trying to say from rows 31 thru 1000, if U and V are zero then hide the
row. if not both zero then show the row.

Having problems putting this into an if statment wondering if I'd be better
served using a case statement but not sure how to write it.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default If or Case help - Which to use

if not both zero then show the row.

If you wish to show them also, perhaps:

Sub Demo()
Dim Rng As Range
For Each Rng In [U31:U1000].Cells
Rng.EntireRow.Hidden = Rng = 0 And Rng(1, 2) = 0
Next Rng
End Sub

--
Dana DeLouis


"Stephen" wrote in message
...
I'm trying to say from rows 31 thru 1000, if U and V are zero then hide
the
row. if not both zero then show the row.

Having problems putting this into an if statment wondering if I'd be
better
served using a case statement but not sure how to write it.


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
countif function: how to distinguish case/make case sensitive mvwoolner Excel Worksheet Functions 3 March 18th 09 02:18 PM
change data of entire column from small case to upper case Ann Excel Worksheet Functions 1 August 16th 08 01:06 PM
Changing multiple cell text from lower case to upper case Patti Excel Discussion (Misc queries) 2 January 4th 08 08:35 PM
excel'03 how to convert a column from upper case to proper case sharie palmer Excel Discussion (Misc queries) 1 January 30th 06 11:50 PM
Change the text from lower case to upper case in an Excel work boo dave01968 Excel Discussion (Misc queries) 2 December 9th 05 09:09 AM


All times are GMT +1. The time now is 03:17 AM.

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"