Thread: Sort problem
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Karen53 Karen53 is offline
external usenet poster
 
Posts: 333
Default Sort problem

Hi,

wbkNew is a global variable already set in another procedure. This value is
correct according to the debug.print statements.
--
Thanks for your help.
Karen53


"Lars-Åke Aspelin" wrote:

On Mon, 14 Apr 2008 12:26:02 -0700, Karen53
wrote:

Hi,

I keep getting a subscript out of range and can't find why. All of my
values are correct. Have I formatted something incorrectly?

Sub SortIDData(ShName, StartCol, EndCol, StartRow, EndRow)

Debug.Print "Starting SortIDData"

Debug.Print "wbkNew.Name " & wbkNew.Name
Debug.Print "ShName " & ShName & _
vbLf & "StartCol " & StartCol & _
vbLf & "StartRow " & StartRow & _
vbLf & "EndCol " & EndCol & _
vbLf & "Endrow " & EndRow

wbkNew.Sheets(ShName).Range(StartCol & StartRow & ":" & _
EndCol &
EndRow).Sort _
Key1:=Sheets(ShName).Range(StartCol & StartRow), _
Order1:=xlDescending, Header:=xlNo, _
OrderCustom:=4, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

End Sub


How does your Sub get to know about wbkNew ??

Lars-Åke