Help edit existing code to combine 2 macros.

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
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,217,127
Messages
6,134,777
Members
449,888
Latest member
webarnes99

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top