View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
dan dungan dan dungan is offline
external usenet poster
 
Posts: 411
Default Sorting left to right

I'm using excel 2000. This code fails at DataOption1--"variable not
defined"

Dan

On Oct 9, 11:07 am, "Gary Keramidas" <GKeramidasATmsn.com wrote:
watch for wordwrap:

Sub test()
Dim lastrow As Long
Dim i As Long
lastrow = Cells(Rows.Count, "B").End(xlUp).Row

For i = 2 To lastrow
With Range("B" & i, Range("B" & i).End(xlToRight))
.Sort Key1:=Range("B" & i), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
End With
Next
End Sub

--

Gary

"LongBeachGuy" wrote in message

ps.com...

I am trying to make the following codes work for multiple rows. So far
I can only do one row at a time. Please help.


Range("B2").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight,
_
DataOption1:=xlSortNormal


How can I make "B2" a variable so that the sort can work it's way down
the sheet?