#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,069
Default Macro File Names

I am trying to create a generic macro that will run a serious of various
commands from one file to another file. The trick is "File A's" name changes
daily. For instance "File A 12/2", "File A 12/3", ETC.... Is there a way to
tell the macro to run off of File A even though the name changes daily?


Sub Amazing()
'
' Amazing Macro
' Macro recorded 12/4/2008 by John
'
' Keyboard Shortcut: Option+Cmd+e
'
Windows("File A 12/2.xls").Activate
Sheets("Agent").Select
Rows("6:2000").Select
Selection.AutoFilter
Selection.AutoFilter Field:=5, Criteria1:="total"
Selection.Sort Key1:=Range("D7"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Selection.AutoFilter Field:=4, Criteria1:="BOB"
Rows("7:2000").Select
Application.CutCopyMode = False
Selection.Copy
Windows("File B.xls").Activate
Range("A3").Select
ActiveSheet.Paste
Windows("File A 12/2.xls").Activate
Selection.AutoFilter Field:=4, Criteria1:="Joe"
Rows("7:2000").Select
Application.CutCopyMode = False
Selection.Copy
Windows("File B.xls").Activate
Range("A5").Select
ActiveSheet.Paste
Windows("File A 12/2.xls").Activate


This is an example of the coding I am trying to use. File A's name changes
every day. File B the macro will rewrite over the previous information. Any
help????


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Macro File Names

This isn't a valid filename in windows: File A 12/2.xls
(no slashes allowed).

Maybe:

workbooks("file A " & format(date,"m-d") & ".xls").activate

But that file would have to be open.

John wrote:

I am trying to create a generic macro that will run a serious of various
commands from one file to another file. The trick is "File A's" name changes
daily. For instance "File A 12/2", "File A 12/3", ETC.... Is there a way to
tell the macro to run off of File A even though the name changes daily?

Sub Amazing()
'
' Amazing Macro
' Macro recorded 12/4/2008 by John
'
' Keyboard Shortcut: Option+Cmd+e
'
Windows("File A 12/2.xls").Activate
Sheets("Agent").Select
Rows("6:2000").Select
Selection.AutoFilter
Selection.AutoFilter Field:=5, Criteria1:="total"
Selection.Sort Key1:=Range("D7"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Selection.AutoFilter Field:=4, Criteria1:="BOB"
Rows("7:2000").Select
Application.CutCopyMode = False
Selection.Copy
Windows("File B.xls").Activate
Range("A3").Select
ActiveSheet.Paste
Windows("File A 12/2.xls").Activate
Selection.AutoFilter Field:=4, Criteria1:="Joe"
Rows("7:2000").Select
Application.CutCopyMode = False
Selection.Copy
Windows("File B.xls").Activate
Range("A5").Select
ActiveSheet.Paste
Windows("File A 12/2.xls").Activate

This is an example of the coding I am trying to use. File A's name changes
every day. File B the macro will rewrite over the previous information. Any
help????


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,346
Default Macro File Names

Try to keep your post to the same thread. That is, don't keep posting the
same question or directly related questions as separate threads, keep them
together.


--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"John" wrote:

I am trying to create a generic macro that will run a serious of various
commands from one file to another file. The trick is "File A's" name changes
daily. For instance "File A 12/2", "File A 12/3", ETC.... Is there a way to
tell the macro to run off of File A even though the name changes daily?


Sub Amazing()
'
' Amazing Macro
' Macro recorded 12/4/2008 by John
'
' Keyboard Shortcut: Option+Cmd+e
'
Windows("File A 12/2.xls").Activate
Sheets("Agent").Select
Rows("6:2000").Select
Selection.AutoFilter
Selection.AutoFilter Field:=5, Criteria1:="total"
Selection.Sort Key1:=Range("D7"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Selection.AutoFilter Field:=4, Criteria1:="BOB"
Rows("7:2000").Select
Application.CutCopyMode = False
Selection.Copy
Windows("File B.xls").Activate
Range("A3").Select
ActiveSheet.Paste
Windows("File A 12/2.xls").Activate
Selection.AutoFilter Field:=4, Criteria1:="Joe"
Rows("7:2000").Select
Application.CutCopyMode = False
Selection.Copy
Windows("File B.xls").Activate
Range("A5").Select
ActiveSheet.Paste
Windows("File A 12/2.xls").Activate


This is an example of the coding I am trying to use. File A's name changes
every day. File B the macro will rewrite over the previous information. Any
help????


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
Open Excel file get error with file names that have spaces in the Kozmo Setting up and Configuration of Excel 6 October 29th 08 02:51 AM
Tab Names in Macro Cheri Excel Discussion (Misc queries) 11 June 29th 07 01:28 AM
Need a macro to include file names in a folder to excel sheet anil Excel Discussion (Misc queries) 0 March 12th 07 09:10 AM
EXCEL97 FILE NAMES TRUNCATED TO THE FIRST LETTER IN THE FILE NAME Geoff Porter New Users to Excel 6 May 25th 06 08:31 PM
VBA: syntax to review macro names in a file? [email protected] Excel Discussion (Misc queries) 2 September 7th 05 10:01 PM


All times are GMT +1. The time now is 05:52 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"