jrobin5881
Technical User
I have a file that I pull down from the mainframe. I wrote a macro that formats the file and opens a template file and then stops. I have been taking the info from the formatted file worksheet, copying and pasting it into the template and saving it.
I recorded a macro to select the range from the template and copy and paste it into the template. I intend to append this snippet to the end of the macro that I have.
Here's the issue: When I recorded the macro it uses the name of the file as a reference of which workbook and worksheet to select from. So I added a variable where my macro stops and I type in the name of the formatted file. The macro then continues and copies and pastes the info just fine. What I'd like to do is NOT have to input the info and programitically have my macro find the name of the workbook and insert it. Here's my code as it exists now:
Sub CutPaste()
'
' CutPaste Macro
' Macro recorded 12/29/2006 by Authorized User
'
WkBk = InputBox("Enter Workbook Name-ie 088.csv")
Windows(WkBk).Activate
Range("J1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("Final_Template.xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("FLTS").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows(WkBk).Activate
Range("S2").Select
End Sub
I recorded a macro to select the range from the template and copy and paste it into the template. I intend to append this snippet to the end of the macro that I have.
Here's the issue: When I recorded the macro it uses the name of the file as a reference of which workbook and worksheet to select from. So I added a variable where my macro stops and I type in the name of the formatted file. The macro then continues and copies and pastes the info just fine. What I'd like to do is NOT have to input the info and programitically have my macro find the name of the workbook and insert it. Here's my code as it exists now:
Sub CutPaste()
'
' CutPaste Macro
' Macro recorded 12/29/2006 by Authorized User
'
WkBk = InputBox("Enter Workbook Name-ie 088.csv")
Windows(WkBk).Activate
Range("J1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("Final_Template.xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("FLTS").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows(WkBk).Activate
Range("S2").Select
End Sub