LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jbm Jbm is offline
external usenet poster
 
Posts: 28
Default 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
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
Current Date Code in form Tony Excel Discussion (Misc queries) 11 September 21st 09 04:12 PM
code that searches for current date J.W. Aldridge Excel Programming 3 October 3rd 07 06:04 PM
Restricting date entry relative to current date bwalshjr Excel Worksheet Functions 1 April 10th 07 12:49 PM
Can I add the current date/time to my code when I print it? Dave F.[_3_] Excel Programming 2 September 14th 04 09:23 AM
code pasting a date changes date format in current month only Edward[_5_] Excel Programming 0 May 10th 04 06:13 PM


All times are GMT +1. The time now is 06:03 AM.

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"