Ok, so I'm using VB 6.0 to create an Excel spreadsheet and once the data has been entered into the sheet, I'd like to sort it before I save the document. Here is the code I have so far when I sort...
Public Sub SortNames(oSheet As Object)
oSheet.Rows("9:32").Select
ActiveWindow.SmallScroll Down:=0
Selection.Sort Key1:=Range("A9"), Order1:=xlAscending, Key2:=Range("B9") _
, Order2:=xlAscending, Key3:=Range("C9"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub
My problem is that once the code runs through the sort, it leaves the Excel.exe running in the background and when my program loops back in again to create another spreadsheet and hits the sorting function, it errors out. So right now only the first spreadsheet is being created, and after that it only errors out. Any help on getting the Excel.exe to close so I can create another spreadsheet?