Macro to Sort

  • Thread starter Thread starter Confused
  • Start date Start date
C

Confused

I have a macro that consolidates multiple sheets into one. I'd like to
include a code in the macro where it sorts the dates (starting in cell b2)
once the consolidation is done. The headings are in row 1, how do I write a
macro where the sort starts in cell b2?
 
hi
do the sort manually with the macro recorder on. the recorder will write the
code for you. after that copy the recorder code and paste it in into your
project.

regards
FSt1
 
I have a macro that consolidates multiple sheets into one.  I'd liketo
include a code in the macro where it sorts the dates (starting in cell b2)  
once the consolidation is done.  The headings are in row 1, how do Iwrite a
macro where the sort starts in cell b2?

Is it possible to see your code?

Thanks
 
Will this work if I keep adding lines to the consolidated sheet? the code
generated using the macro recorder ends at the last cell where it contains a
value.
 
Here is the code to where it consolidates all the individual worksheets.


Sub consolidatesheets()
Application.ScreenUpdating = False

With Sheets("Consolidated")
Rows("2:" & Cells(2, 1).End(xlDown).Row).Delete

For Each sh In ThisWorkbook.Sheets

If LCase(Left(sh.Name, 1)) = "1" Then
dlr = .Cells(Rows.Count, 1).End(xlUp).Row + 1
slr = sh.Cells(Rows.Count, 1).End(xlUp).Row
If slr > 1 Then sh.Cells(2, 1).Resize(slr, 16).Copy .Cells(dlr, 1)
End If

Next sh

Columns("A:p").HorizontalAlignment = xlCenter
End With

Application.ScreenUpdating = True
End Sub
 
Back
Top