ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding new workbook! (https://www.excelbanter.com/excel-programming/302343-adding-new-workbook.html)

aiyer[_26_]

Adding new workbook!
 
Hi all!

A quick question.
I wanted to add a new workbook(book1 is default) and copy all th
columns/rows from the existing workbook (vtec.sls) to the new one.
After that I would like to manipulate the new workbook(book1), withou
changes to the original one and I would like to do this multipl
times.
I.e., the next workbook to be added would be book3 and then book 4 an
so on.... But before book3 is added, book2 has to be closed withou
saving the changes.
I was wondering how to implement this using macros and would appreciat
any help guys.


Thanks alot.
Arun...
Vtec corp

--
Message posted from http://www.ExcelForum.com


mudraker[_275_]

Adding new workbook!
 
a couple of examles on how to do it once.

You would need to repeat code for multiple times or inclose in a FO
loop



Sub Macro1()
Dim wsData As Worksheet
Set wsData = ActiveSheet

Workbooks.Add
wsData.Cells.Copy
ActiveSheet.Paste

'your manipulation code here

ActiveWindow.Close savechanges:=False

End Sub

Sub Macro2()
Dim wsData As Worksheet
Set wsData = ActiveSheet

Workbooks.Add
wsData.Copy Befo=ActiveWorkbook.Sheets(1)
'your manipulation code here
ActiveWindow.Close savechanges:=False
End Su

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 08:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com