LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default autosort

Dear Anthony

I understand you want the blank cells to remain where they are. Try the
below in ColA and feedback.

ColA with the below values (row 4 and row7 blank)
10,7,1, ,2,3, ,6,5,9
will be turned to the below(row 4 and row7 blank)
1,2,3, ,5,6, ,7,9,10


Sub SortWOBlanks()
Dim lngRow As Long
Dim lngCount As Long
Dim lngLastRow As Long
Dim varTemp As Variant
Dim arrTemp As Variant

Application.ScreenUpdating = False
lngLastRow = Range("A" & Rows.Count).End(xlUp).Row
varTemp = Range("A1:A" & lngLastRow)
Range("A1:A" & lngLastRow).Sort Key1:=Range("A1")
lngRow = Range("A" & Rows.Count).End(xlUp).Row
arrTemp = Range("A1:A" & lngLastRow)
Range("A1:A" & lngLastRow) = varTemp
For lngRow = 1 To lngLastRow
If Range("A" & lngRow) < "" Then
lngCount = lngCount + 1
Range("A" & lngRow) = arrTemp(lngCount, 1)
End If
Next
Application.ScreenUpdating = True

End Sub



If this post helps click Yes
---------------
Jacob Skaria


"Anthony" wrote:

autosort with blank cell not moving eg
1-3-5-2-4- "-represent blank cell" when sorting i want
1-2-3-4-5- leaving blank cells where thy are

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
autosort Anthony Excel Programming 1 July 13th 08 08:45 AM
autosort left to right Anthony Excel Programming 1 July 12th 08 02:11 PM
Autosort on an Array [email protected] Excel Programming 7 April 20th 07 03:45 PM
autosort pete Excel Worksheet Functions 1 April 25th 06 11:02 PM
AutoSort in VBA tamato43 Excel Discussion (Misc queries) 1 March 30th 05 08:09 AM


All times are GMT +1. The time now is 12:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"