View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove[_2_] Harlan Grove[_2_] is offline
external usenet poster
 
Posts: 1,231
Default how do I view excel rows in name order infirst column?

Buglebeek1 wrote...
I want to view name labels in alphabetical order in that I label in
the first column. How can I adjust the column after I add new names?


You'd need to sort the entire table. You could use an event handler
macro, specifically, a Change event handler, to sort the table upon
any entry in the first column.

For example, with the table range identified by the sheet-level
defined name tbl, and assuming tbl contains headers in its first row,


Private Sub Worksheet_Change(ByVal Target As Range)
'put table range's name here - change as needed
Const NMDRNG As String = "tbl"

Dim t As Range, n As Long

Set t = Names(NMDRNG).RefersToRange
n = t.Columns.Count
Set t = t.Resize(t.End(xlDown).Row - t.Row, 1).Offset(1, 0)

'exit quickly if no change in 1st col of named range
If Intersect(Target, t) Is Nothing Then Exit Sub

On Error GoTo CleanUp
Application.EnableEvents = False

t.Resize(, n).Sort _
key1:=t.Cells(1, 1), _
Order1:=xlAscending, _
Header:=xlNo

CleanUp:
Application.EnableEvents = True
End Sub