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: 2
Default Using a string variable to change a file name

I need to open and paste information from four different files each day of
the week (ie there is a "MON PERFORM and a TUE PERFORM etc..."- I have
written this initially seven times in seven separate macros (which works)
but thought of passing the day value as a string and using a CommandClick()
proceedure from seven separate buttons to change the "day" each time but it
doesn't work as it stands now (I've never pased an argument before so this
is new territory for me) - have I done something daft?

Appreciate any help on this - thanks Gaz.


Sub Day_Dump(day As String)
'
'
Workbooks.Open Filename:=ThisWorkbook.Path & "\" & day & " PERFORM.csv"

Cells.Select
Selection.Copy
Windows("LSM DUMP v2.3.xls").Activate
Sheets("LSM Performance Report Dump").Select
Range("A1").Select
ActiveSheet.Paste
Windows(day & " PERFORM.csv").Activate
Application.CutCopyMode = False
ActiveWindow.Close
Windows("LSM DUMP v2.3.xls").Activate

Workbooks.Open Filename:=ThisWorkbook.Path & "\" & day & " PROMIS.csv"

Cells.Select
Selection.Copy
Windows("LSM DUMP v2.3.xls").Activate
Sheets("LSM Promis Dump").Select
Range("A1").Select
ActiveSheet.Paste
Windows(day & " PROMIS.csv").Activate
Application.CutCopyMode = False
ActiveWindow.Close
Windows("LSM DUMP v2.3.xls").Activate

Workbooks.Open Filename:=ThisWorkbook.Path & "\" & day & " JAMS.csv"

Cells.Select
Selection.Copy
Windows("LSM DUMP v2.3.xls").Activate
Sheets("LSM Jams Dump").Select
Range("A1").Select
ActiveSheet.Paste
Windows(day & " JAMS.csv").Activate
Application.CutCopyMode = False
ActiveWindow.Close
Windows("LSM DUMP v2.3.xls").Activate

Workbooks.Open Filename:=ThisWorkbook.Path & "\" & day & " BOX.csv"

Cells.Select
Selection.Copy
Windows("LSM DUMP v2.3.xls").Activate
Sheets("LSM Box Monitor Dump").Select
Range("A1").Select
ActiveSheet.Paste
Windows(day & " BOX.csv").Activate
Application.CutCopyMode = False
ActiveWindow.Close
Windows("LSM DUMP v2.3.xls").Activate

ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("OEE Input Data").Select
Calculate
End Sub


Private Sub CommandButton1_Click()
Call Day_Dump("MON")
End Sub

Private Sub CommandButton1_Click()
Call Day_Dump("TUE")
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
Trying To Append String Variable To Another String Variable Joe K. Excel Programming 3 October 6th 07 02:11 AM
Setting a string variable as the file name [email protected] Excel Discussion (Misc queries) 1 March 28th 07 11:10 PM
Getting text file into a VBA string variable Don Wiss Excel Programming 10 January 7th 05 12:42 AM
How to activate a file when the filename is represented by a string variable news.sintef.no Excel Programming 4 February 6th 04 02:17 PM
Using a variable string in a file save path Ron[_13_] Excel Programming 1 October 16th 03 08:29 PM


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

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"