Thread: Select Case
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
jlclyde jlclyde is offline
external usenet poster
 
Posts: 410
Default Select Case

On Jan 6, 2:00*pm, Mike H wrote:
One more point, unless you really want to do it with select case there's a
simpler way. Looping through the same range of A1 - A10 backwards you could
do this

For i = 10 To 1 Step -1
* * If Cells(i, 1).Value = Sheets("Sheet4").Range("C4").Value Then
* * * * * *Cells(i, 1).EntireRow.Delete
* * End If
Next i

Mike



"Mike H" wrote:
Hi,


A couple of points. You haven't defined Rng and sheet4.range is incorrect
syntax.
The solution below used Sheets(4) which is the fourth worksheet in the
workbook irrespective of name. *But you could use


Sheets("Sheet4").Range("C4")


for the worksheet called Sheet4


Sub sonic()
Set Rng = Range("A1:A10")
For Each i In Rng
* * Select Case i
* * * * Case Is = Sheets(4).Range("C4")
* * * * * * i.EntireRow.Delete
* * End Select
Next i


End Sub


Mike


"jlclyde" wrote:


I am trying to use Select Case. *Sheet4.Range("C4") = 103, 113, 123,
220 and so on. *I am trying to look up all of the i's in Rng and
determine if any of them are = to Sheet4.Range("C4"). *this is the
code I have. *It does not work as is.


Thanks,
Jay


For Each i In Rng
* * Select Case i
* * * * Case Sheet4.Range("C4")
* * * * * * i.EntireRow.Delete
* * End Select
Next i- Hide quoted text -


- Show quoted text -


I like this answer to simplify things. But still C4 is not a number,
it is a series of numbers. What can be done about this?
Jay