Tuesday 26 November 2013

How to add new workbook using excel macro?

Below code will add new workbook and write some data into it and save it as well.

Sub Add_New_Workbook()

'We can add new workbook by using add method of workbooks collection

Set new_workbook = Workbooks.Add

'access the cells in first sheet from the newly added workbook
new_workbook.Worksheets(1).Cells(1, 1) = "obama"

'save new workbook to hard disk
new_workbook.SaveAs "c:\temp.xlsx"

'close new workbook
new_workbook.Close

'release the memory of the object associated with new_workbook
Set new_workbook = Nothing

End Sub


What do you think on above excel macro topic? Please provide your input, comments, questions on excel macro. I will try to reply as soon as possible. I value your opinion on Excel Macros.

No comments:

Post a Comment

Popular Posts

Search This Blog