ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   how do I view excel rows in name order infirst column? (https://www.excelbanter.com/excel-worksheet-functions/166399-how-do-i-view-excel-rows-name-order-infirst-column.html)

Buglebeek1

how do I view excel rows in name order infirst column?
 
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?

Harlan Grove[_2_]

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

Gord Dibben

how do I view excel rows in name order infirst column?
 
Select column A and DataSortAscending


Gord Dibben MS Excel MVP

On Fri, 16 Nov 2007 10:50:03 -0800, 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?




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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com