Sorting multiple lists (dynamic ranges)

dasadler

New Member
Joined
Aug 12, 2010
Messages
4
Hello,

Sorry if this has been asked before - my forum search did not find it.

Using Excel 2007, I have a worksheet with about 30 lists (30 columns). Each list is defined as:

=Lists!$A$1:INDEX(Lists!$A:$A,COUNTA(Lists!$A:$A))
=Lists!$B$1:INDEX(Lists!$B:$B,COUNTA(Lists!$B:$B))
=Lists!$C$1:INDEX(Lists!$C:$C,COUNTA(Lists!$C:$C))
=Lists!$D$1:INDEX(Lists!$D:$D,COUNTA(Lists!$D:$D))
and so on

What i would like to do is for these lists to be sorted alphabetically any time any of the lists are changed (item added, deleted, or edited).

Maybe sort all the lists when the workbook is opened then sort only the list that has been changed... that sounds more efficient. Since none of the lists have more than 50 items, efficiency may not be a consideration.

I would appreciate any thoughts on this or code I can enter into the Lists! worksheet to make this happen.

Thank you.
 
Last edited:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
You could try this worksheet change event code in a copy of your workbook. I have assumed headings in your lists. To implement ..
1. Right click the 'Lists' sheet name tab and choose "View Code".
2. Copy and Paste the code below into the main right hand pane that opens at step 1.
3. Close the Visual Basic window & test.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim rCol As Range

  For Each rCol In Target.Columns
    With rCol.EntireColumn
      .Sort key1:=.Cells(1), Order1:=xlAscending, Header:=xlYes
    End With
  Next rCol
End Sub
 
Upvote 0
Peter, thank you for the reply. My lists do not have headings so how must I modify the code for that?.. change it to Header:=xlNo?
 
Upvote 0

Forum statistics

Threads
1,215,429
Messages
6,124,835
Members
449,192
Latest member
mcgeeaudrey

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