LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default VBA code relative to current date

I added an inport box to select the rows you want. I also added a new workbook

Sub DataMove()

Set SrcSht = Sheets("Sheet1")

Set Newbk = Workbooks.Add
Set DestSht = Newbk.Sheets("Sheet1")

SrcSht.Activate
Set MyCell = Application.InputBox( _
prompt:="Select Row to Export", _
Type:=8)

Set SrcSht = MyCell.Parent
FirstRow = MyCell.Row
LastRow = FirstRow + MyCell.Rows.Count - 1

NewRow = 1
RowCount = 1

With SrcSht
For RowCount = FirstRow To LastRow
Keyword = .Range("B" & RowCount)
If Keyword = "wood" Or _
Keyword = "stone" Or _
Keywood = "tile" Then

DestSht.Cells(NewRow, "H").Value = .Cells(RowCount, "A")
DestSht.Cells(NewRow, "J").Value = .Cells(RowCount, "B")
DestSht.Cells(NewRow, "K").Value = .Cells(RowCount, "C")
DestSht.Cells(NewRow, "G").Value = .Cells(RowCount, "D")
NewRow = NewRow + 1
End If
RowCount = RowCount + 1
Next RowCount
End With
End Sub


"Jbm" wrote:

Joel,
I'm afraid I'm being counterproductive here. Let my try to simplify this.
Don't worry about keywords for this example at all.
Imagine I have the dates in column A like this, with corresponding data in
column B

Column A
7/01/09
7/01/09
7/02/09
7/02/09
7/02/09
7/03/09
7/03/09

Now suppose the date is 7/03/09, so in this instance I need to copy rows 3-5
(data from the previous day) and place that data in Columns D and E. So
Column D would look like this

Column D
7/02/09
7/02/09
7/02/09

And Column E would have the corresponding data to those dates that was in B.
I need to do this every day, with a separate new document, so for today (the
29th), I need Column D to hold only data from the 28th. The last cell in A
will always contain the current date. I'm sorry to have wasted your effort
on the previous code, but I think this will get at what I'm trying to do with
better accuracy. Thanks.

 
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 03:12 PM.

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

About Us

"It's about Microsoft Excel"