View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default sorting multiple-area selection

If those values in column A are typed in -- not formulas, then this may work for
you:

Option Explicit
Sub testme()
Dim myRng As Range
Dim myArea As Range
Dim wks As Worksheet

Set wks = Worksheets("sheet1")

With wks
Set myRng = Nothing
On Error Resume Next
Set myRng = .Range("a:a").Cells.SpecialCells(xlCellTypeConstan ts)
On Error GoTo 0
End With

If myRng Is Nothing Then
MsgBox "No constants here!"
Exit Sub
End If

For Each myArea In myRng.Areas
With myArea
.Cells.Sort key1:=.Columns(1), order1:=xlAscending, header:=xlNo
End With
Next myArea

End Sub




??? wrote:

Dear friends

Is it possible to select in one column only those cells with data and to
sort them with code? for example:

A1
A2 2
A3 1
A4 3
A5
A6 6
A7 5

And I want it to be:
A1
A2 1
A3 2
A4 3
A5
A6 5
A7 6

Thanks in advance for your help.


--

Dave Peterson