Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Open Excel file get error with file names that have spaces in the | Setting up and Configuration of Excel | |||
Tab Names in Macro | Excel Discussion (Misc queries) | |||
Need a macro to include file names in a folder to excel sheet | Excel Discussion (Misc queries) | |||
EXCEL97 FILE NAMES TRUNCATED TO THE FIRST LETTER IN THE FILE NAME | New Users to Excel | |||
VBA: syntax to review macro names in a file? | Excel Discussion (Misc queries) |