Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 414
Default Automatic Sorting and Inserting Rows

I need to sort dates in a single column and group them so that different
dates are separated by an inserted row. Is there a way to do this without
performing it manually? Any help would be greatly appreciated!

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Automatic Sorting and Inserting Rows

The macro below will work on the active sheet if the dates are in Column A

Sub InsertRows()

LastRow = Range("A" & Rows.Count).End(xlUp).Row

For RowCount = (LastRow - 1) To 1 Step -1
If Range("A" & RowCount) < Range("A" & (RowCount + 1)) Then
Rows(RowCount + 1).Insert
End If
Next

"Andy" wrote:

I need to sort dates in a single column and group them so that different
dates are separated by an inserted row. Is there a way to do this without
performing it manually? Any help would be greatly appreciated!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,389
Default Automatic Sorting and Inserting Rows

One option is to use DataSubtotal. It will insert a line after each date
group. It has the additional benefit of summing other columns, which you may
find useful. If not, have it sum a hidden column.

Regards,
Fred.

"Andy" wrote in message
...
I need to sort dates in a single column and group them so that different
dates are separated by an inserted row. Is there a way to do this without
performing it manually? Any help would be greatly appreciated!


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 414
Default Automatic Sorting and Inserting Rows

Joel, thanks a lot! Macro works just as I wanted. However, there is an
important detail that I failed to mention. The first four rows of the data I
am working with are text titles, meaning that I would not want to separate
different rows until the fifth row down. If this macro could work for dates
only, or for all rows after the fourth, it would be perfect! Again, I truly
appreciate the help- it will make a big difference for everyone at work.

Thanks

"Joel" wrote:

The macro below will work on the active sheet if the dates are in Column A

Sub InsertRows()

LastRow = Range("A" & Rows.Count).End(xlUp).Row

For RowCount = (LastRow - 1) To 1 Step -1
If Range("A" & RowCount) < Range("A" & (RowCount + 1)) Then
Rows(RowCount + 1).Insert
End If
Next

"Andy" wrote:

I need to sort dates in a single column and group them so that different
dates are separated by an inserted row. Is there a way to do this without
performing it manually? Any help would be greatly appreciated!

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,389
Default Automatic Sorting and Inserting Rows

Change this line:
For RowCount = (LastRow - 1) To 1 Step -1

to
For RowCount = (LastRow - 1) To 5 Step -1

Regards,
Fred.

"Andy" wrote in message
...
Joel, thanks a lot! Macro works just as I wanted. However, there is an
important detail that I failed to mention. The first four rows of the data
I
am working with are text titles, meaning that I would not want to separate
different rows until the fifth row down. If this macro could work for
dates
only, or for all rows after the fourth, it would be perfect! Again, I
truly
appreciate the help- it will make a big difference for everyone at work.

Thanks

"Joel" wrote:

The macro below will work on the active sheet if the dates are in Column
A

Sub InsertRows()

LastRow = Range("A" & Rows.Count).End(xlUp).Row

For RowCount = (LastRow - 1) To 1 Step -1
If Range("A" & RowCount) < Range("A" & (RowCount + 1)) Then
Rows(RowCount + 1).Insert
End If
Next

"Andy" wrote:

I need to sort dates in a single column and group them so that
different
dates are separated by an inserted row. Is there a way to do this
without
performing it manually? Any help would be greatly appreciated!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting Blank rows after every row upto 2500 rows Manju Excel Worksheet Functions 8 August 22nd 06 12:54 PM
Inserting automatic text in Excel [email protected] Excel Worksheet Functions 1 June 8th 06 12:21 PM
Inserting pictures then sorting Dav Excel Discussion (Misc queries) 2 November 3rd 05 11:39 AM
Inserting Automatic Date Johnathon Aaron Steel Excel Worksheet Functions 3 September 19th 05 06:56 PM
Realtime Automatic sorting of data in rows in new work sheet Gazzali Excel Worksheet Functions 0 June 23rd 05 09:35 AM


All times are GMT +1. The time now is 05:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"