Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 17
Default Change Filename in Macro

Hi,

I have the following Macro that I have a question on. The filename
("XX-TEST-0301.xls") will always be a different name, how can I update the
Macro to work when the filename changes?

Workbooks.Open Filename:= _
"J:\Blank Templates\Sales Process Templates\WIP\Work Order -
Upload\Estimate Spreadsheet-NEW Test 1.xls"
Sheets("Estimate Template").Select
Sheets("Estimate Template").Copy After:=Sheets(1)
Windows("XX-TEST-0301.xls").Activate
Range("A1:F30").Select
Selection.Copy
Windows("Estimate Spreadsheet-NEW Test 1.xls").Activate
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select

Thank you,
Havenstar
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Change Filename in Macro

One way is to allow the user to pick the name:

Sub dural()
Dim s As String
s = Application.InputBox(prompt:="enter file name", Type:=2)
Windows(s).Activate
End Sub

--
Gary''s Student - gsnu200826


"Havenstar" wrote:

Hi,

I have the following Macro that I have a question on. The filename
("XX-TEST-0301.xls") will always be a different name, how can I update the
Macro to work when the filename changes?

Workbooks.Open Filename:= _
"J:\Blank Templates\Sales Process Templates\WIP\Work Order -
Upload\Estimate Spreadsheet-NEW Test 1.xls"
Sheets("Estimate Template").Select
Sheets("Estimate Template").Copy After:=Sheets(1)
Windows("XX-TEST-0301.xls").Activate
Range("A1:F30").Select
Selection.Copy
Windows("Estimate Spreadsheet-NEW Test 1.xls").Activate
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select

Thank you,
Havenstar

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 17
Default Change Filename in Macro

Hi,

Not sure if that is what I would like to accomplish. Actually, the filename
that will be changing is the actual Workbook with the Macro Button on. Does
that make a difference?

Thanks.
Havenstar

"Gary''s Student" wrote:

One way is to allow the user to pick the name:

Sub dural()
Dim s As String
s = Application.InputBox(prompt:="enter file name", Type:=2)
Windows(s).Activate
End Sub

--
Gary''s Student - gsnu200826


"Havenstar" wrote:

Hi,

I have the following Macro that I have a question on. The filename
("XX-TEST-0301.xls") will always be a different name, how can I update the
Macro to work when the filename changes?

Workbooks.Open Filename:= _
"J:\Blank Templates\Sales Process Templates\WIP\Work Order -
Upload\Estimate Spreadsheet-NEW Test 1.xls"
Sheets("Estimate Template").Select
Sheets("Estimate Template").Copy After:=Sheets(1)
Windows("XX-TEST-0301.xls").Activate
Range("A1:F30").Select
Selection.Copy
Windows("Estimate Spreadsheet-NEW Test 1.xls").Activate
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select

Thank you,
Havenstar

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 17
Default Change Filename in Macro

Hi,

I have figured out i changed "Windows("XX-TEST-0301.xls")" to "ThisWorkbook"

Thanks
Havenstar


"Havenstar" wrote:

Hi,

Not sure if that is what I would like to accomplish. Actually, the filename
that will be changing is the actual Workbook with the Macro Button on. Does
that make a difference?

Thanks.
Havenstar

"Gary''s Student" wrote:

One way is to allow the user to pick the name:

Sub dural()
Dim s As String
s = Application.InputBox(prompt:="enter file name", Type:=2)
Windows(s).Activate
End Sub

--
Gary''s Student - gsnu200826


"Havenstar" wrote:

Hi,

I have the following Macro that I have a question on. The filename
("XX-TEST-0301.xls") will always be a different name, how can I update the
Macro to work when the filename changes?

Workbooks.Open Filename:= _
"J:\Blank Templates\Sales Process Templates\WIP\Work Order -
Upload\Estimate Spreadsheet-NEW Test 1.xls"
Sheets("Estimate Template").Select
Sheets("Estimate Template").Copy After:=Sheets(1)
Windows("XX-TEST-0301.xls").Activate
Range("A1:F30").Select
Selection.Copy
Windows("Estimate Spreadsheet-NEW Test 1.xls").Activate
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select

Thank you,
Havenstar

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
macro reference changes with filename Louis Sweere Excel Discussion (Misc queries) 1 November 7th 07 11:47 AM
Excel macro to prompt for filename [email protected] Excel Discussion (Misc queries) 8 January 4th 07 01:31 AM
filename in macro ynissel Excel Discussion (Misc queries) 7 June 12th 06 08:41 PM
Put Filename Variable in Macro David Excel Discussion (Misc queries) 4 December 27th 05 06:27 PM
Recorded macro: What happens if I change filename? [email protected] Excel Discussion (Misc queries) 2 January 26th 05 11:54 PM


All times are GMT +1. The time now is 08:30 AM.

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"