LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default Quick sort problem

Thanks very much! With your notes below, I was able to take a targeted look
at the entire code; as usual, this problem was due to my own general lack of
coding skills (I originally had 'Skip Blanks = False' when copying over data
from the source worksheet). The following now seems to be working well.

SuzLeigh

ActiveSheet.Unprotect
Sheets("IHSF DATA ENTRY").Range("B2:T500").Copy

With Sheets("MERGE DATA IHSF")
.Range("D2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=True, Transpose:=False
End With

Dim Rng As Range
Set Rng = .Range(.Range("V1"), .Cells(Rows.Count, "B").End(xlUp))
Rng.SORT Key1:=.Cells(2, "B"), Order1:=xlAscending, MatchCase:=False,
Header:=xlYes
..Range("A13").Select

End With


"Joel" wrote:

The solution may be different depending on these reason for the empty rows.
If the empty rows are at the end of the rows of data then only copy the cells
that have data.

First try changing this statement

from
Sheets("IHSF DATA ENTRY").Range("B2:T500").Copy
to
with Sheets("IHSF DATA ENTRY")
LastRow = .Range("B" & rows.count).end(xlup).row
.Range("B2:T" & LastRow).Copy
end with

If the blank rows are in the midle of the orginal data then you have to
delete the empty rows after you sort

FirstRow = Range("A1").End(xlDown).Row
LastRow = FirstRow - 1
Rows("1:" & LastRow).Delete

The sometimes the rows appear to be empty but are not. then I go back to
the original worksheet and delete all empty rows and columns.

Start by going to cell A1 and press Cntl-Shift Down-Arror to get to the last
row. Hightlight the 1st empty row and then Cntrl-Shift Down-Arro. the is
should highlight all the empty rows. Then delete these rows.

Repeat process for columns. Now rerun the macro.

"Suzanne" wrote:

ok... how do I exclude empty rows?

"Joel" wrote:

The blank cells in column B are being put at the top of the sort area.
Sometimes you think cells are blank but are not.



"Suzanne" wrote:

Ok, changing the sort key did not help until I adjusted the range (from "A"
to "B")

Now... why are the 103 rows of data getting thrown down to row 83?


I'm executing [SORRY! Meant to say "DeleteIHSFMerge"] prior to executing
"GetIHSFMerge" (see code below)

Sub GetIHSFMerge()

ActiveSheet.Unprotect

Sheets("IHSF DATA ENTRY").Range("B2:T500").Copy

With Sheets("MERGE DATA IHSF")
.Range("D2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
End With

Dim Lrow As Long
With ActiveSheet
Lrow = Range("D" & Rows.Count).End(xlUp).Row
Range("B2:C" & Lrow).FillDown
Range("AA2:AL" & Lrow).FillDown

Dim Rng As Range
Set Rng = .Range(.Range("V1"), .Cells(Rows.Count, "B").End(xlUp))

Rng.SORT key1:=.Cells(2, "B"), Order1:=xlAscending, MatchCase:=False,
Header:=xlYes

.Range("A13").Select

End With

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

End Sub

Sub DeleteIHSFMerge()
ActiveSheet.Unprotect
Range("B3:C500").Select
Selection.ClearContents
Range("D2:V500").Select
Selection.ClearContents
Range("A13").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

 
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
Quick Sort Beth Excel Discussion (Misc queries) 2 November 24th 08 08:38 PM
Sort Problem Patrick Simonds Excel Programming 3 November 26th 05 11:02 AM
Quick question - quick answer about assigning shortcut keys funkymonkUK[_75_] Excel Programming 1 October 13th 05 10:50 AM
Quick way to sort lists by text color? PokerZan Excel Discussion (Misc queries) 3 June 3rd 05 01:09 AM
Multi-column two-dimensional quick sort Marston Excel Programming 3 August 11th 04 07:00 PM


All times are GMT +1. The time now is 11:58 PM.

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"