Open, insert data , rename, save and print batch

jakewatson

New Member
Joined
Jun 10, 2019
Messages
6
Hi Guru's/Geniuses,

I have a template which uses VLookup to get data from a master spreadsheet. All of the lookup data is from a list of code numbers on the master spreadsheet.
I need to be able to:

1. Open the template
2. Insert the code number
3. Save the file as the code number (plus possibly another generic text string, for example "Reference number T34876"
4. Print the document (Although I can batch this if necessary separately)
5. Re-open the template and start the process again with the next code number on the spreadsheet.

I have a few hundred to do so am looking for a Batch solution, but haven't used any kind of VBA/Macro in the past. So any advice or ideas would be appreciated.

Hope That all makes sense, thanks in advance!!!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi Jake,
Run this after you enter your code number
Code:
Sub RunAfterEnterCodeNumber()
'
' Run this after you enter the code number in B2
'
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Users\...\Code-" & Range("b2").Value & ".xlsm" _
        , FileFormat:=xlOpenXMLWorB2kbookMacroEnabled, CreateBackup:=False
    Workbooks.Open Filename:="C:\Users\...Template.xlsm"
End Sub
I do not know where you template is so I use3 C:\Users\...\, change it with your real value
I do not know where the code mumbrer is so I use B2, change it with your real value
Cheers
Sergio
 
Upvote 0

Forum statistics

Threads
1,224,748
Messages
6,180,721
Members
452,995
Latest member
isldboy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top