LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default How to change to not active workbook

I recorded the code below to sort my list of employees, and on it's own it
works great. My problem is that while I have WorkBook open it is not the
Active WorkBook. I am calling the sort routine from within another WorkBook.


Private Sub CommandButton1_Click()

'Sort by Fixed Route Driver Names

Application.Run "EmployeeList.xls!FRDSort"

End Sub

================================================== =====

Sub FRDSort()

'Sort by Fixed Route Drivers Names

Module1.Disable_Events
Module1.UnprotectWorkSheet

Range("B1").Value = "3"

ActiveWorkbook.Worksheets("Employee_List").Sort.So rtFields.Clear
ActiveWorkbook.Worksheets("Employee_List").Sort.So rtFields.Add
Key:=Range( _
"F2:F300"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=
_
xlSortNormal
ActiveWorkbook.Worksheets("Employee_List").Sort.So rtFields.Add
Key:=Range( _
"D2:D300"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=
_
xlSortNormal
With ActiveWorkbook.Worksheets("Employee_List").Sort
.SetRange Range("A2:I300")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A1").Select

Module1.Enable_Events
Module1.ProtectWorkSheet

End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing Hidden Workbook when Active Workbook is Closed SusanK521 Excel Programming 5 September 24th 05 12:27 AM
Undesired change of active workbook keithb Excel Programming 3 August 16th 05 07:15 AM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM
Copy Modules from One workbook to Active Workbook Jim Gifford Excel Programming 1 November 18th 03 12:30 PM
Preventing opening workbook inside active workbook. Serge[_4_] Excel Programming 2 November 4th 03 07:51 PM


All times are GMT +1. The time now is 07:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"