View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel[_511_] joel[_511_] is offline
external usenet poster
 
Posts: 1
Default Sorting with macro


Do you want to sort the entire row? I would use special cell method to
get the visible rows then use sort on the visible object. the code
assumes there is a header row. The sort won't work if the key property
of the sort is not in the filtered data. I'm using column P to perform
the sort.

LastRow = Range("A" & Rows.count).end(xlup).row
Set DataRange = rows("1:" & LastRow)
set VisibleRows = DataRange.SpecialCells(xlCellTypeVisible)

VisibleRows.sort _
header:=xlyes, _
key1:=range("P1"),
order1:=xlascending


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=168751

Microsoft Office Help