Full Version: Sorting On A Dynamic Range
UtterAccess Discussion Forums > Microsoft® Office > Microsoft Excel
kwillis74
Hi I'm trying to run a sort using the following code
[code]
With xlWBTemp.Worksheets(1).Sort
.SetRange xlWBTemp.Worksheets(1).Range("A1:" & xlWBTemp.Worksheets(1).UsedRange.Columns.Count & xlWBTemp.Worksheets(1).UsedRange.Rows.Count)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
[\code]

It errors when i try to run it, at a guess because the column returns a number instead of a letter, can anyone tell me the right way of doing this

cheers

Keith
kwillis74
nevermind, solved it with

.SetRange xlWBTemp.Worksheets(1).Range(xlWBTemp.Worksheets(1).Cells(1, 1), xlWBTemp.Worksheets(1).Cells(xlWBTemp.Worksheets(1).UsedRange.Rows.Count, xlWBTemp.Worksheets(1).UsedRange.Columns.Count))
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.