Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Calling another workbook

The code below is run by clicking on a UserForm button which is part of
WorkBook Vacation.xls. Is there any way to perform this with out making
Employee List.xls active or to return me to where I was in Vacation.xls
after the sort is complete?


Sub PT_Driver_Last_Name_Sort()
'
' Macro1 Macro
' Macro recorded 12/20/2005 by Cathy Baker
'
'Sort by Paratransit Drivers Last Name

Windows("Employee List.xls").Activate
Worksheets("Employee_List").Range("AA1").Value = 2

Dim wks As Worksheet
Set wks = Worksheets("Employee_List")
With wks.Range("A1:Z300")
..Sort Key1:=wks.Range("E2"), Order1:=xlAscending, Key2:=wks.Range("F2") _
, Order2:=xlAscending, Key3:=wks.Range("A2"), Order3:=xlAscending,
Header:= _
xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:=
_
xlSortNormal
End With

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Calling another workbook

Remove this line:

Windows("Employee List.xls").Activate


Sub PT_Driver_Last_Name_Sort()
'
' Macro1 Macro
' Macro recorded 12/20/2005 by Cathy Baker
'
'Sort by Paratransit Drivers Last Name


Worksheets("Employee_List").Range("AA1").Value = 2

Dim wks As Worksheet
Set wks = Worksheets("Employee_List")
With wks.Range("A1:Z300")
...Sort Key1:=wks.Range("E2"), Order1:=xlAscending, Key2:=wks.Range("F2") _
, Order2:=xlAscending, Key3:=wks.Range("A2"), Order3:=xlAscending,
Header:= _
xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:=
_
xlSortNormal
End With

End Sub

--
Regards,
Tom Ogilvy

"Patrick Simonds" wrote:

The code below is run by clicking on a UserForm button which is part of
WorkBook Vacation.xls. Is there any way to perform this with out making
Employee List.xls active or to return me to where I was in Vacation.xls
after the sort is complete?


Sub PT_Driver_Last_Name_Sort()
'
' Macro1 Macro
' Macro recorded 12/20/2005 by Cathy Baker
'
'Sort by Paratransit Drivers Last Name

Windows("Employee List.xls").Activate
Worksheets("Employee_List").Range("AA1").Value = 2

Dim wks As Worksheet
Set wks = Worksheets("Employee_List")
With wks.Range("A1:Z300")
..Sort Key1:=wks.Range("E2"), Order1:=xlAscending, Key2:=wks.Range("F2") _
, Order2:=xlAscending, Key3:=wks.Range("A2"), Order3:=xlAscending,
Header:= _
xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:=
_
xlSortNormal
End With

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Calling another workbook

The problem with that is that Vaction.xls is the active workbook and this
code is performing a sort on Employee List.xls.

"Tom Ogilvy" wrote in message
...
Remove this line:

Windows("Employee List.xls").Activate


Sub PT_Driver_Last_Name_Sort()
'
' Macro1 Macro
' Macro recorded 12/20/2005 by Cathy Baker
'
'Sort by Paratransit Drivers Last Name


Worksheets("Employee_List").Range("AA1").Value = 2

Dim wks As Worksheet
Set wks = Worksheets("Employee_List")
With wks.Range("A1:Z300")
..Sort Key1:=wks.Range("E2"), Order1:=xlAscending, Key2:=wks.Range("F2") _
, Order2:=xlAscending, Key3:=wks.Range("A2"), Order3:=xlAscending,
Header:= _
xlYes, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:=
_
xlSortNormal
End With

End Sub

--
Regards,
Tom Ogilvy

"Patrick Simonds" wrote:

The code below is run by clicking on a UserForm button which is part of
WorkBook Vacation.xls. Is there any way to perform this with out making
Employee List.xls active or to return me to where I was in Vacation.xls
after the sort is complete?


Sub PT_Driver_Last_Name_Sort()
'
' Macro1 Macro
' Macro recorded 12/20/2005 by Cathy Baker
'
'Sort by Paratransit Drivers Last Name

Windows("Employee List.xls").Activate
Worksheets("Employee_List").Range("AA1").Value = 2

Dim wks As Worksheet
Set wks = Worksheets("Employee_List")
With wks.Range("A1:Z300")
..Sort Key1:=wks.Range("E2"), Order1:=xlAscending, Key2:=wks.Range("F2")
_
, Order2:=xlAscending, Key3:=wks.Range("A2"),
Order3:=xlAscending,
Header:= _
xlYes, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal,
DataOption3:=
_
xlSortNormal
End With

End Sub





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Calling another workbook

Disregard I posted before your update.

"Patrick Simonds" wrote in message
...
The problem with that is that Vaction.xls is the active workbook and this
code is performing a sort on Employee List.xls.

"Tom Ogilvy" wrote in message
...
Remove this line:

Windows("Employee List.xls").Activate


Sub PT_Driver_Last_Name_Sort()
'
' Macro1 Macro
' Macro recorded 12/20/2005 by Cathy Baker
'
'Sort by Paratransit Drivers Last Name


Worksheets("Employee_List").Range("AA1").Value = 2

Dim wks As Worksheet
Set wks = Worksheets("Employee_List")
With wks.Range("A1:Z300")
..Sort Key1:=wks.Range("E2"), Order1:=xlAscending, Key2:=wks.Range("F2")
_
, Order2:=xlAscending, Key3:=wks.Range("A2"), Order3:=xlAscending,
Header:= _
xlYes, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal,
DataOption3:=
_
xlSortNormal
End With

End Sub

--
Regards,
Tom Ogilvy

"Patrick Simonds" wrote:

The code below is run by clicking on a UserForm button which is part of
WorkBook Vacation.xls. Is there any way to perform this with out making
Employee List.xls active or to return me to where I was in Vacation.xls
after the sort is complete?


Sub PT_Driver_Last_Name_Sort()
'
' Macro1 Macro
' Macro recorded 12/20/2005 by Cathy Baker
'
'Sort by Paratransit Drivers Last Name

Windows("Employee List.xls").Activate
Worksheets("Employee_List").Range("AA1").Value = 2

Dim wks As Worksheet
Set wks = Worksheets("Employee_List")
With wks.Range("A1:Z300")
..Sort Key1:=wks.Range("E2"), Order1:=xlAscending, Key2:=wks.Range("F2")
_
, Order2:=xlAscending, Key3:=wks.Range("A2"),
Order3:=xlAscending,
Header:= _
xlYes, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal,
DataOption3:=
_
xlSortNormal
End With

End Sub







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Calling another workbook

Lets try again -- I hit send too soon.

Sub PT_Driver_Last_Name_Sort()
'
' Macro1 Macro
' Macro recorded 12/20/2005 by Cathy Baker
'
'Sort by Paratransit Drivers Last Name

Dim bk as Workbook
set bk = Workbooks("Employee List.xls").
bk.Worksheets("Employee_List").Range("AA1").Value = 2

Dim wks As Worksheet
Set wks = bk.Worksheets("Employee_List")
With wks.Range("A1:Z300")
.Sort Key1:=wks.Range("E2"), Order1:=xlAscending, _
Key2:=wks.Range("F2"),Order2:=xlAscending, _
Key3:=wks.Range("A2"), Order3:=xlAscending, _
Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal
End With

End Sub

--
Regards,
Tom Ogilvy


"Patrick Simonds" wrote:

The code below is run by clicking on a UserForm button which is part of
WorkBook Vacation.xls. Is there any way to perform this with out making
Employee List.xls active or to return me to where I was in Vacation.xls
after the sort is complete?


Sub PT_Driver_Last_Name_Sort()
'
' Macro1 Macro
' Macro recorded 12/20/2005 by Cathy Baker
'
'Sort by Paratransit Drivers Last Name

Windows("Employee List.xls").Activate
Worksheets("Employee_List").Range("AA1").Value = 2

Dim wks As Worksheet
Set wks = Worksheets("Employee_List")
With wks.Range("A1:Z300")
..Sort Key1:=wks.Range("E2"), Order1:=xlAscending, Key2:=wks.Range("F2") _
, Order2:=xlAscending, Key3:=wks.Range("A2"), Order3:=xlAscending,
Header:= _
xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:=
_
xlSortNormal
End With

End Sub





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Calling another workbook

Thank you that did the trick.

"Tom Ogilvy" wrote in message
...
Lets try again -- I hit send too soon.

Sub PT_Driver_Last_Name_Sort()
'
' Macro1 Macro
' Macro recorded 12/20/2005 by Cathy Baker
'
'Sort by Paratransit Drivers Last Name

Dim bk as Workbook
set bk = Workbooks("Employee List.xls").
bk.Worksheets("Employee_List").Range("AA1").Value = 2

Dim wks As Worksheet
Set wks = bk.Worksheets("Employee_List")
With wks.Range("A1:Z300")
.Sort Key1:=wks.Range("E2"), Order1:=xlAscending, _
Key2:=wks.Range("F2"),Order2:=xlAscending, _
Key3:=wks.Range("A2"), Order3:=xlAscending, _
Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal
End With

End Sub

--
Regards,
Tom Ogilvy


"Patrick Simonds" wrote:

The code below is run by clicking on a UserForm button which is part of
WorkBook Vacation.xls. Is there any way to perform this with out making
Employee List.xls active or to return me to where I was in Vacation.xls
after the sort is complete?


Sub PT_Driver_Last_Name_Sort()
'
' Macro1 Macro
' Macro recorded 12/20/2005 by Cathy Baker
'
'Sort by Paratransit Drivers Last Name

Windows("Employee List.xls").Activate
Worksheets("Employee_List").Range("AA1").Value = 2

Dim wks As Worksheet
Set wks = Worksheets("Employee_List")
With wks.Range("A1:Z300")
..Sort Key1:=wks.Range("E2"), Order1:=xlAscending, Key2:=wks.Range("F2")
_
, Order2:=xlAscending, Key3:=wks.Range("A2"),
Order3:=xlAscending,
Header:= _
xlYes, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal,
DataOption3:=
_
xlSortNormal
End With

End Sub





Reply
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
Calling macros in another workbook Nick Wright Excel Worksheet Functions 1 January 12th 06 04:03 PM
Trouble with Calling a workbook Rbp9ad[_2_] Excel Programming 5 October 8th 05 07:58 AM
Calling another workbook not working malik641 Excel Worksheet Functions 2 June 24th 05 07:36 PM
Reference code in another workbook from a calling workbook Datasort Excel Programming 1 January 4th 05 01:13 AM
calling sub from another workbook James[_9_] Excel Programming 1 October 14th 03 06:06 PM


All times are GMT +1. The time now is 02:59 AM.

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

About Us

"It's about Microsoft Excel"