Sort by cell contents

J

Jbm

Using a macro in Excel 2007. I have a cell in P1 with a date in it, and I
need to pull data from G-K that correspond to this date (dates are held in
column G). The code I have looks like this but does not work. I am certain
the line 'If c.Value Like "Range(P1).value" Then' is wrong, but I don't know
how to compare a c.value to a cell value. Thanks for the help.

Sub Test()
RowCount = 1
For Each c In Range("G:G")
If c.Value Like "Range(P1).value" Then
Cells(RowCount, "R").Value = c.Value
Cells(RowCount, "S").Value = c.Offset(0, 1).Value
Cells(RowCount, "T").Value = c.Offset(0, 2).Value
Cells(RowCount, "U").Value = c.Offset(0, 3).Value
Cells(RowCount, "V").Value = c.Offset(0, 4).Value
RowCount = RowCount + 1
End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top