Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA code relative to current date
Hi,
I'm working with Excel 2007, and every day I receive a new automatically generated worksheet with data from every day of that month up to and including the current day. So column A contains the date, looks something like: 7/01/2009 7/01/2009 7/01/2009 7/02/2009 7/02/2009 etc. Suppose that I get the worksheet for 7/29/2009, in which case I need to pull out data only from 7/28/2009. Furthermore I only need to pull data from that date that contains certain keywords, like "wood" and "tile." The current solution I can think of would be to either pull all the data by keyword, and then run something that eliminates any of that data that isn't the desired date. Or, there may be a way to look at the last non empty cell in A, subtract 1 from that date and then use that new date as the criteria for what data the macro pulls. The current macro I built pulls the data by keyword, but not by date, so maybe either modify this macro or write a new, simpler one? Sub DataMove() RowCount = 1 For Each c In Range("B:B") If c.Value Like "*Wood*" Or _ c.Value Like "*Stone*" Or _ c.Value Like "*Tile*" Then Cells(RowCount, "H").Value = c.Value Cells(RowCount, "I").Value = c.Offset(0, 1).Value Cells(RowCount, "J").Value = c.Offset(0, 2).Value Cells(RowCount, "K").Value = c.Offset(0, 3).Value Cells(RowCount, "G").Value = c.Offset(0, -1).Value RowCount = RowCount + 1 End If Next End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Current Date Code in form | Excel Discussion (Misc queries) | |||
code that searches for current date | Excel Programming | |||
Restricting date entry relative to current date | Excel Worksheet Functions | |||
Can I add the current date/time to my code when I print it? | Excel Programming | |||
code pasting a date changes date format in current month only | Excel Programming |