Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Jbm Jbm is offline
external usenet poster
 
Posts: 28
Default Sort by cell contents

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

Reply
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
concatenate contents of cells whose contents resemble cell referem cathyh Excel Worksheet Functions 3 May 23rd 09 12:16 PM
how do I sort rows by the contents of one cell bhaight58 Excel Discussion (Misc queries) 1 March 28th 09 08:07 PM
Excel Sort Contents of cells Bob Excel Discussion (Misc queries) 4 September 18th 06 08:06 AM
How do I sort contents alphabetically in Excel? Lila Bean Excel Discussion (Misc queries) 1 May 4th 06 05:41 PM
Macro to remove contents of cell and move all other contents up one row adw223 Excel Discussion (Misc queries) 1 July 1st 05 03:57 PM


All times are GMT +1. The time now is 03:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"