Returning cells with ID column in another sheet

  • Thread starter Thread starter Patrick
  • Start date Start date
P

Patrick

Sheet 1 has a list of names in column B, with a letter in
column A representing a section (A,B,or C).

I want a formula in sheet 2 that will return all the
names from Sheet 1 with an A in column 1.

ex.

Sheet 1
Section Name
A Name 1
B Name 2
A Name 3
C Name 4
A Name 5
B Name 6
C Name 7
C Name 8
A Name 9

Sheet 2
Section Name
A Name 1
A Name 3
A Name 5
A Name 9


Any chance?
 
try this:

Sub test()
Application.ScreenUpdating = False
With Worksheets("Sheet1")
Set rng = .Range("A2:A" & .Range("A" & Rows.Count).End
(xlUp).Row)
For Each cell In rng
If cell.Value = "A" Then
With Worksheets("Sheet2")
..Range("A65536").End(xlUp).Offset(1, 0) = cell.Value
..Range("B65536").End(xlUp).Offset(1, 0) = cell.Offset(0,
1).Value
End With
End If
Next cell
End With
Application.ScreenUpdating = True
End Sub

Gareth
 
Back
Top