PDA

View Full Version : Halp: Excel Conundrum


BrotherMan
11-08-2007, 10:28 PM
Column A is filled with n number of restaurants.
Column B is filled with an equal number of =rand().
Column C has five cells, C1 = A1, C2 = A2 and so on.
I can manually sort by Column B, being sure to select the "No Header row" radial.

The macro to do this:

Columns("A:B").Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

Works okay, except once in a while it gets wonky on me and leaves A1 the same item no matter what the rand() is. At this point, reverting to the manual sort can fix it. But it will eventually revert to using row 1 as header space.

Is there a kind and compassionate codemonkey that can see anything obvious?

Crumb
11-08-2007, 10:35 PM
Change xlGuess to xlNo for your Header

BrotherMan
11-09-2007, 02:07 AM
Thanks, co... Crumb! :cheer:

I know exactly nothing about VB scripting and didn't want to break anything.

:stupidme:

Crumb
11-09-2007, 02:30 AM
No problemo. :)