Reputation: 13
I am trying to move data from a 5 column spread sheet in excel to other sub spread sheets based on one of the date columns in the first spread sheet. The sub-spreadsheets will be created if they do not exist, otherwise they will be populated with data from the master spreadsheet. The spread sheets names will be a date that is the start of the week(being monday). my columns are: Work Order, Description, Location, Asset, Date.
Example:
Work Order - Description - Location - Asset - Date
123 ---------- test&inspect - NC-231 - KK32 - 8/21/14
In this example my master spreadsheet with a date row of 8/21/14 will create a subspread sheet with a name of 8/18/14 since this row falls in the week of 8/18/14 and insert the other columns with it. How can this be done inside of an excel workbook?
Upvotes: 1
Views: 2374
Reputation: 758
Dim firstDate As Date, secondDate As Date
Dim I as Date
firstDate = Inputbox("What start date?") ' request your input for what date Monday is
secondDate = DateAdd("d", 6, firstDate)
For Each Cell in Range("E2"),Range("E2").End(xldown)
ActiveCell = Cell
If cell => firstdate and =< secondate then ' test if falls under days of week
ActiveCell.Row.Copy
On error resume next
Worksheets.Add.Name = Firstdate
Sheets(" & Firstdate &").Select
Range("A1").End(lxDown).Offset(1,0).pastespecial
Next Cell
End Sub
Not tested but should be a start .
Upvotes: 0