View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ardus Petus
 
Posts: n/a
Default Selecting rows based on cell entries

Sub selectAge12()
Dim rngSel As Range
Dim c As Range
For Each c In Range( _
Cells(2, "B"), _
Cells(Rows.Count, "B"))

If c.Value = 12 Then
If rngSel Is Nothing Then
Set rngSel = c.EntireRow
Else
Set rngSel = Union(rngSel, c.EntireRow)
End If
End If
Next c
rngSel.Select
End Sub

HTH
--
AP

"m.cain" a écrit dans
le message de ...

Hello,

I want to select specific rows from a sequential list based on a cell
value.

Example:

Name: Age:
Mark 12
Luke 15
Jon 14
Matthew 12
Fred 12

I want a method of selecting only rows where Age is 12. Note that I
don't want to have to manually select each row, or even sort them by
age and then select each row manually. I want an automatic method that
I could use in a macro eventually.


--
m.cain
------------------------------------------------------------------------
m.cain's Profile:

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