call new workbook

  • Thread starter Thread starter Kirsty
  • Start date Start date
K

Kirsty

I am trying to have my macro open a workbook during the run.
I recorded the macro, and opened the workbook, however, when I now run the
workbook, this is not working. Can anyone help me with how to open a new
workbook during a macro
 
'To open new workbook
Workbooks.Add

'To open existing workbook
workbooks.Open "<filename>"
 
DIM wb as WorkBook
SET wb = Workbooks.Add()

you can now control the workbook using the variable

eg save is
wb.SaveAs {params}
wb.Close {params}

DIM ws as Worksheet
set ws = wb.ActiveSheet

and so on
 
Back
Top