VBA Code to Seperate a Column into Worksheets By Date Column
I have a list of data that has a specific date value for each row, and I want to separate the data by date using VBA. I would like to create a new worksheet for each date found and paste the ENTIRE ROW to the created worksheet based on date. I know this is going to create a lot of worksheets, but that's ok -- because the next step is analyzing the time column to break the data down further into Day/Night based on time.
Good Luck...
I don't presume to know what I am doing, however, just like you, I too started somewhere...
One-day, One-problem at a time!!!
If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
Also....Add a comment if you like!!!!
And remember...Mark Thread as Solved...
Excel Forum Rocks!!!
According to your attachment a VBA demonstration as a beginner starter to paste to the Sheet13 (Sheet1) worksheet module :
PHP Code:
Sub Demo1()
Dim V, W, S$
Application.ScreenUpdating = False
With [A1].CurrentRegion
.Columns(2).AdvancedFilter 2, , [K1], True
V = [K1].CurrentRegion.Rows.Count - 1
V = Application.Small([K2].Resize(V).Value2, Evaluate("ROW(1:" & V & ")"))
For Each W In V
[K2].Value2 = W: S = Format$(W, "mm-dd-yyyy")
If Evaluate("ISREF('" & S & "'!A1)") Then Sheets(S).UsedRange.Clear Else Sheets.Add(, Sheets(Sheets.Count)).Name = S
.AdvancedFilter 2, [K1:K2], Sheets(S).[A1]
Next
End With
[K1].CurrentRegion.Clear
Application.ScreenUpdating = True
End Sub
► Do you like it ? ► ► So thanks to click on bottom left star icon « ★ Add Reputation » ! ◄ ◄
Both solutions work great. One question for Marc L --- How can I get this to copy and paste the entire row. My sample sheet didnt have the 6 other columns with data included and I need to include that data in the new sheet along with the filtered result
Re: VBA Code to Seperate a Column into Worksheets By Date Column
It's what happens when the attachment does not well reflect the real workbook …
My demonstration copies all the contiguous data so not a concern if there is no blank column between data,
but in case of non contiguous data you may use Resize or UsedRange statement …
Re: VBA Code to Seperate a Column into Worksheets By Date Column
I just need it to bring the information in columns A, B, & D to the new workbook it creates based on the date. There will be no blank rows in the date column, I am looking for/correcting for that prior to running this routine.
Bookmarks