Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default How to auto Sort list after entering last item in a row.

Hi,

I have an excel list with 9 columns, the first heading is date, the last is
total.

I need to enter a batch of records into separate rows under the headings,
with each record having a different date. Is there any way that the entire
list could be sorted by date every time I press enter after entering all the
data in the list (I dont want to click the A to Z icon each row or at the end
of data entry if possible.

Note: the last column sums several cells within the data record.

Thanks for any help on this.

Craig

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to auto Sort list after entering last item in a row.

Assuming headers are in row1, a1:I1

Right click on sheet tab and select view code.

put in code similar to this:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
On Error GoTo ErrHandler
If IsEmpty(Target) Then Exit Sub
If Target.Column = 9 Then
Application.EnableEvents = False
Set rng1 = Range("A1").CurrentRegion
Set rng1 = rng.Resize(rng1.Rows.Count - 1)
rng1.Sort Key1:=Range("A1"), Order1:=xlAscending, _
Header:=xlYes
End If
ErrHandler:
Application.EnableEvents = True

End Sub

--
Regards,
Tom Ogilvy

"Craig" wrote in message
...
Hi,

I have an excel list with 9 columns, the first heading is date, the last

is
total.

I need to enter a batch of records into separate rows under the headings,
with each record having a different date. Is there any way that the

entire
list could be sorted by date every time I press enter after entering all

the
data in the list (I dont want to click the A to Z icon each row or at the

end
of data entry if possible.

Note: the last column sums several cells within the data record.

Thanks for any help on this.

Craig



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default How to auto Sort list after entering last item in a row.

Thank you Tom...I put in this exact code into the code window and tried but
it did not automatically sort the list after I pressed enter in column I.

Any thoughts?

Appreciate any help...thanks very much

Craig

"Tom Ogilvy" wrote:

Assuming headers are in row1, a1:I1

Right click on sheet tab and select view code.

put in code similar to this:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
On Error GoTo ErrHandler
If IsEmpty(Target) Then Exit Sub
If Target.Column = 9 Then
Application.EnableEvents = False
Set rng1 = Range("A1").CurrentRegion
Set rng1 = rng.Resize(rng1.Rows.Count - 1)
rng1.Sort Key1:=Range("A1"), Order1:=xlAscending, _
Header:=xlYes
End If
ErrHandler:
Application.EnableEvents = True

End Sub

--
Regards,
Tom Ogilvy

"Craig" wrote in message
...
Hi,

I have an excel list with 9 columns, the first heading is date, the last

is
total.

I need to enter a batch of records into separate rows under the headings,
with each record having a different date. Is there any way that the

entire
list could be sorted by date every time I press enter after entering all

the
data in the list (I dont want to click the A to Z icon each row or at the

end
of data entry if possible.

Note: the last column sums several cells within the data record.

Thanks for any help on this.

Craig




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
How 2 sort an autosum total list after adding items 2 autosum item akm Excel Discussion (Misc queries) 0 May 30th 10 11:44 PM
how to auto extract item# upon entering a date Meeru Excel Discussion (Misc queries) 9 September 8th 09 04:56 PM
Auto sort function for a list Ben Excel Discussion (Misc queries) 1 May 5th 09 07:58 PM
How to Auto-populate cell based on selection of a list item AK9955 Excel Discussion (Misc queries) 2 April 30th 07 10:04 AM
Excel Auto Filter: WHY'S SORT @ TOP OF LIST? WHEN I KEY TO "SHOW . Dan W Excel Worksheet Functions 0 December 1st 04 03:53 PM


All times are GMT +1. The time now is 01:49 AM.

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

About Us

"It's about Microsoft Excel"