Need help on deleting row.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Below is a macro I created in sorting out a worksheet. The macro works well
but the only problem is that sort result have data that are not needed like
titles subtitles, etc. I need to add some more code to clean out the
unneeded rows which contain strings and are all over the rows and columns so
that when I execute the macro all I would see are the sorted data that I
want. Thanks for your help.


Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range("B1") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortNormal
 
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range("B1")
_
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=
_
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortNormal
Range(Selection,
ActiveCell.SpecialCells(xlLastCell)).SpecialCells(xlConstants,
xlTextValues).EntireRow.Delete

perhaps. Test on a copy of your data.
 
This does not work. It is giving an error message "Cannot use that command on
overlappping selections."
--
scaps


Tom Ogilvy said:
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range("B1")
_
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=
_
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortNormal
Range(Selection,
ActiveCell.SpecialCells(xlLastCell)).SpecialCells(xlConstants,
xlTextValues).EntireRow.Delete

perhaps. Test on a copy of your data.
 
Back
Top