LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
PPL PPL is offline
external usenet poster
 
Posts: 18
Default Problem with the "Or" operand in Excel

Excel 2002/3
I am trying to write a short script that looks at all cells in column C and
if the cell contains a selected name (i.e., Fred or John or Mary) then the
entire row is hidden
I would have thought that the following would have doen it?

Sub MyHideRows()
Dim startrow As Integer
startrow = 1
Do Until startrow Cells(Cells.Rows.Count, "C").End(xlUp).Row
If Cells(startrow, 3).Value < "Fred" _
Or Cells(startrow, 3).Value < "John" _
Or Cells(startrow, 3).Value < "Mary" Then

Cells(startrow, 3).Select
Selection.EntireRow.Hidden = True
End If

startrow = startrow + 1
Loop
End Sub

The result is that regardless of content the script hides all rows

Interstingly if I strip out the "Or" operands and leave the basic "If"
statement it works fine.
So this works:

If Cells(startrow, 3).Value < "Fred" Then
Cells(startrow, 3).Select
Selection.EntireRow.Hidden = True
End If

Can somebody please please help me with the logic here (or my lack of same!)

TIA

Phil





 
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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
problem with Linking workbooks via "copy" and "paste link" Arkitek Excel Discussion (Misc queries) 0 December 19th 06 10:03 PM
Problem: Worksheets("New Style 2006").Unprotect Password:="naPrint" Karoo News[_2_] Excel Programming 1 January 30th 06 02:40 PM
Problem with "On error resume next" with "custom VLookup" Factivator Excel Programming 3 July 20th 04 04:42 PM


All times are GMT +1. The time now is 06:07 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"