Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
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 |