C
CellShocked
Hey guys n gals,
Happy New Year!
I am creating a macro to alphabetize a list of names that will slowly
increase in length over time.
I know where the first cell in the list is, but I do not know where the
end is.
I use a named range to print my report references.
Ocaissonally I add a name and want to use this macro to sort the list.
My problem is that I always will want to select all the non-empty cells
within that named range.
I know there is a string which takes me to the last filled cell in a
column, but I cannot remember it.
So, I want my script to select the entire filled data set within named
range.
This is my current recording, which selects directly, without the named
range (which always starts at C18. So the script I need could ignore the
named range, and simply step down to the last filled cell.
My desire is to highlight that list, before the A to Z sort. The list
is always alpha and zero numerics.
Unless there is some shorter script for selecting and sorting a single
column list which also includes header fields, etc. This is why I
thought that a named range would work.
But I also have blank cell in that range which makes for blank lines in
the report so that they can be hand filled (it is a daily test data log)
Sub AlphaTize()
'
' AlphaTize Macro
'
' Alphabetize the long name listing
'
Range("C18:C80").Select
Range("C80").Activate
ActiveWorkbook.Worksheets("Info_Page").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Info_Page").Sort.SortFields.Add
Key:=Range("C80") _
, SortOn:=xlSortOnValues, Order:=xlAscending,
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Info_Page").Sort
.SetRange Range("C19:C80")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Happy New Year!
I am creating a macro to alphabetize a list of names that will slowly
increase in length over time.
I know where the first cell in the list is, but I do not know where the
end is.
I use a named range to print my report references.
Ocaissonally I add a name and want to use this macro to sort the list.
My problem is that I always will want to select all the non-empty cells
within that named range.
I know there is a string which takes me to the last filled cell in a
column, but I cannot remember it.
So, I want my script to select the entire filled data set within named
range.
This is my current recording, which selects directly, without the named
range (which always starts at C18. So the script I need could ignore the
named range, and simply step down to the last filled cell.
My desire is to highlight that list, before the A to Z sort. The list
is always alpha and zero numerics.
Unless there is some shorter script for selecting and sorting a single
column list which also includes header fields, etc. This is why I
thought that a named range would work.
But I also have blank cell in that range which makes for blank lines in
the report so that they can be hand filled (it is a daily test data log)
Sub AlphaTize()
'
' AlphaTize Macro
'
' Alphabetize the long name listing
'
Range("C18:C80").Select
Range("C80").Activate
ActiveWorkbook.Worksheets("Info_Page").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Info_Page").Sort.SortFields.Add
Key:=Range("C80") _
, SortOn:=xlSortOnValues, Order:=xlAscending,
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Info_Page").Sort
.SetRange Range("C19:C80")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub