BurritoBill
New Member
- Joined
- Nov 18, 2014
- Messages
- 1
Hi Everyone,Below is my current macro that, at this moment i am happy with. It is working how i want it to in my test workbook. It may need tweaking when I implement it in my live workbook.
Basically what it is doing is pulling all data from 2 worksheets (Pre-Sales and Post-Sales) and populating a 3rd worksheet (Summary), Whilst ignoring a hidden 4th worksheet (Drop Down). Every-time the command button is clicked on the "Summary" worksheet the macro is run and the "Summary" worksheet clears all of its content and loops through the previously mentioned worksheets and populates all the data.
I now want all the rows of data on only the "Summary" worksheet to be automatically ordered by date oldest to newest. I am aware you cant run 2 separate macros but you can combine 2. Could you please help me to add/edit the below code to do this for me.
I have headings in row 1 from A - K, the date heading is in column I so the date begin in I2.
I DO NOT want just the date column to arrange itself in order from oldest to most recent. I want the entire row of data to be arranged by date from oldest to most recent depending on that rows date cell found in column I.
How do i edit the below code to do this.
Any help will be greatly appreciated.
Sub Summarize()
Dim ws As Worksheet
Dim lastRng As Range
Application.ScreenUpdating = False 'speed up code
ThisWorkbook.Sheets("Summary").Range("A2:K1000").ClearContents 'clear
For Each ws In ThisWorkbook.Worksheets
Set lastRng = ThisWorkbook.Sheets("Summary").Range("A65536").End(xlUp).Offset(1, 0)
Select Case ws.Name
Case "Summary", "Drop Down" 'exlude
'do nothing
Case Else
ws.Activate
'copy data from individual sheets
Range("A2", Range("K1000").End(xlUp)).Copy lastRng.Offset
End Select
Next
Application.CutCopyMode = False 'clear clipboard
Application.ScreenUpdating = True
Sheets("Summary").Activate
End Sub
Basically what it is doing is pulling all data from 2 worksheets (Pre-Sales and Post-Sales) and populating a 3rd worksheet (Summary), Whilst ignoring a hidden 4th worksheet (Drop Down). Every-time the command button is clicked on the "Summary" worksheet the macro is run and the "Summary" worksheet clears all of its content and loops through the previously mentioned worksheets and populates all the data.
I now want all the rows of data on only the "Summary" worksheet to be automatically ordered by date oldest to newest. I am aware you cant run 2 separate macros but you can combine 2. Could you please help me to add/edit the below code to do this for me.
I have headings in row 1 from A - K, the date heading is in column I so the date begin in I2.
I DO NOT want just the date column to arrange itself in order from oldest to most recent. I want the entire row of data to be arranged by date from oldest to most recent depending on that rows date cell found in column I.
How do i edit the below code to do this.
Any help will be greatly appreciated.
Sub Summarize()
Dim ws As Worksheet
Dim lastRng As Range
Application.ScreenUpdating = False 'speed up code
ThisWorkbook.Sheets("Summary").Range("A2:K1000").ClearContents 'clear
For Each ws In ThisWorkbook.Worksheets
Set lastRng = ThisWorkbook.Sheets("Summary").Range("A65536").End(xlUp).Offset(1, 0)
Select Case ws.Name
Case "Summary", "Drop Down" 'exlude
'do nothing
Case Else
ws.Activate
'copy data from individual sheets
Range("A2", Range("K1000").End(xlUp)).Copy lastRng.Offset
End Select
Next
Application.CutCopyMode = False 'clear clipboard
Application.ScreenUpdating = True
Sheets("Summary").Activate
End Sub