Create A New Workbook By Vba Of Excel

May 31, 2006

I want to the following steps to be done by vba of excel.

1. copy ranges of cells in the active worksheet (sheet3)
2. add a new workbook and paste the copied ranges to sheet1
3. save the new workbook with the new file name (e.g. date)
4. close the new workbook and clear the contents the copied ranges of cells in old workbook.

following code and make it more simpler?


Worksheets("Sheet3").Activate
If Range("l1").Value <> "" Then
Range("l1").Value = CDate(Date)
End If
asdate = Range("l1").Value 'date entered by user
resp4 = MsgBox(" Case particulars of " & asdate & " will be backed up and deleted from this sheet! Proceed? (Y/N)", vbYesNo, "Deletion of Data")
If resp4 = 7 Then
Exit Sub

View 11 Replies


ADVERTISEMENT

Create Authorization Workbook With Excel?

Oct 23, 2012

I'm working on a time system tracking, and I want to know if it's possible to have a button for authorization (and sent by mail to me) to authorize or reject the workbook..

do this automatically in vba macros?

View 1 Replies View Related

Excel VBA To Create New Workbook And Name Worksheets Within

Nov 15, 2011

Code that will autofilter my sheet for rows that contain either a 1,2,3, or 4 in Column "Z". Then, create a new workbook for each unique value in column "O" and save that to a folder on my desktop named "Contracts". Next, while still filtered by by "Z" and for every unique value in column "O", filter and name a sheet in the new workbook for each unique value in column "B". Finally, while the main sheet is filtered I need to copy and paste the visible cells (minus header row) from columns C,D,E,F,G,H,S, and U to consecutive columns in the newly created worksheet beginning in cell "A9".

I am using excel to create some contracts for a few partners. Each partner could work with several of my clients and I need to give each partner a personalized contract for each of my clients with which they work.

I hope my description of the problem is not too confusing. If so, let me know and I will try to clarify exactly what I am trying to say.

I have tried to combine some code that I already have but, being a newb with loops, I can't seem to get it to do everything.

View 1 Replies View Related

Use Vba To Create Copies Of Excel Workbook For Different Users?

Nov 26, 2012

I have an excel workbook that serves as a master workbook. I have to create 30 copies of this workbook, 1 for each site. Each workbook will have small differences in the data held. This is because I will refresh the sheet before saving it. There is a dropdown list on the 1st tab of the workbook that contains the names of the sites. The sequense, I suppose would be like: select the next name on the dropdown list"calculate" the spreadsheet to enable the refreshsome sort of "save-as" with the name from the dropdown list forming the name of the file. The Master file must be kept intact.select the next name from the dropdown listcalculate the sheet ........and so on I have a few other things I will add to the script like Protect Sheet etc.

View 1 Replies View Related

How To Create Copy Of Excel Workbook In Same Directory

Mar 20, 2014

I have Workbook named"Test_Template" in below specified path this is not the active workbook.

It is saved in strFName = ThisWorkbook.Path & "Backup" & "Test_Template.xlsx"

I need to create a copy of the same workbook named as "Copy_Test_Template.xlsx" in the same folder(Backup), same specified path on button click.

[Code] .....

But this creates a "Copy_Test_Template.xlsx outside the Backup folder, i want it in the back up folder.

View 2 Replies View Related

Create Formula Using 2 Different Tabs Within Excel Workbook

Apr 24, 2014

I need to create a formula using 2 different tabs within an excel workbook. I need to search column A on the first tab and column A on the second tab and if they match I need to compare column F on the first tab to column F on the second tab. (This column contains my staff names but the problem I am running into is on the first tab their names are listed first name last name and on the second tab they are listed last name, first name). If column A and F match I need to search column H on the first tab to column H on the second tab. If all columns match up to this point I need to take the data in column Q on the second tab and in put it into column K on the first tab. Is this even possible?

View 2 Replies View Related

Excel 2013 :: Create New Workbook And Copy Sheet To It

Feb 13, 2014

I was given a spread sheet that prepares a file for export to some ones system. The macro in the spread sheet wouldn't run as I'm using excel 2013 which when you open a new work book it only opens sheet 1 and there was a bit in the macro that wanted to send information to sheet 2 which wasn't there. I added a bit of code which created sheet 2 and hey presto it worked fine. I made the mistake of telling the people who supplied the original workbook to me what I had done so that they could pass the modified sheet on to other users in case they had the same problem.

Now I've been asked if I could do a bit more work to the existing macro so that instead of the new workbook just being called Book 1 could I add a name and date to the new workbook being created.

I've had a look at the original code and it looks like it would be quicker to start from scratch as I cant follow the original code.

The existing workbook has 3 sheets, I want to copy sheet2 to the new workbook. I want to name the new workbook as "a fixed name" with the "time and date " .xlsx

View 9 Replies View Related

Excel 2007 :: Create A Main Macro To Control Other Macros Within A Workbook?

Nov 7, 2012

"How to create a 'main' macro to control other macros within a workbook". I have my individual macros created. There's one macro for each sheet that searches online data and returns the information. I have one of these per sheet (a total of 20 sheets) since I couldn't find a way to have all 20 macros be on one sheet and still work. My trouble is that whenever I'm on my 'main' sheet and try to run the macro which applies to a 'secondary' sheet, I get an error. I have to select the sheet first, then run the macro and it works. Below is the macro on each sheet.

VB:
Sub Holding1()
Dim DataSheet As Worksheet
Dim EndDate As Date [code].....

View 8 Replies View Related

Excel Macro To Create New Workbook Based On Category In List With Respective Sheets

Apr 27, 2014

I need new workbooks based on category name in the below list. Respective sheets should be copied from the existing workbook with items as sheet names. List can be updatable.

category(workbookname)Items(sheets)
Vegetables carrot
vegetables brinjal
meat chicken
meat Fish
meat Mutton
grains Wheat
grains Rice

View 4 Replies View Related

Delete Sheets And Create New Workbook In Shared Workbook

Jun 2, 2014

I wrote a code in unshared workbook and it works fine. But when i make it shared i get Run-time error '1004' Delete method of worksheet class failed.

The Deleting of worksheet only occurs once (when the new wb is created) so is there i can unshare and share it back when the process is complete?

View 3 Replies View Related

Create New Workbook With Separate Sheets From Data In Another Workbook

Jul 16, 2012

I have been tasked with creating a macro which creates a new workbook wherein each sheet contains the information for one site from the active sheet. The active sheet already has the values sorted by the site such that all information needing to be copied from the active sheet into the new workbook is together.

I.E.

ATL
ATL
ATL
ATL
CEN
CEN
JCK
JCK
etc.

There are 8 different sites on the active sheet: ATL, CEN, DAL, HAR, JAS, JCK, VIS, NOV

The macro needs to find the range for all of the data of each site and copy/paste that data into a new workbook such that ATL would have its own sheet, CEN would have its own sheet, and so on. The data ranges from A:R.

So, for example, the macro would find that the last row with ATL in the "B" column is 6095 and would then copy A2:R6095 and insert that data into the new workbook under Sheet 1.

I had some code that I had adapted to select the range for each of them, but the code loops through the entire sheet (which is 44,307 rows long) for each site making it a quite clunky and very slow step in an even longer macro. Since the data is already sorted, I know there must be a way to have the macro stop searching when it reaches data not equal to the data the row before, however, my experience with VBA is limited, and I have been unable to find a solution. Also, the data does not have to be conserved after being sent to the new workbook, if that would speed up the macro.

View 5 Replies View Related

Macro To Create New Workbook And Sheets Inside Each Workbook

Mar 31, 2009

I have a spreadsheet which has all the names of trips from a warehouse, the day that they operate (1,2,3 etc) and the job line allocated to each trip. It looks something like that:

A B C
DAYTRIPCUST

I would like to create a macro that will be creating 7 new workbooks and then in those workbooks as many sheets as the trips. In these sheets, the customers should be displayed.

How do I write it? I could not find how to have a "dynamic choice" in the macro. I.e. not to have the criteria as "1", "trips1" but to choose from the range of inputs that are available.

View 9 Replies View Related

Copy From Closed Workbook Then Create New Workbook

Jan 31, 2007

I've got a problem with this code, have been wracking my brains about. Here is the process I am trying to do:

1) Copy a range (a2:av1000) but (ideally) find the last populated row from a closed workbook (with a different password)
2) Create a new workbook and paste this data into it at A2
3) Close all the workbooks but only save the new one.

View 9 Replies View Related

Excel 2007 :: Create Visio Diagram From Excel?

May 9, 2014

I need to write a code to create visio flow diagram with excel inputs(Excel 2007). Attached is the requirement.

Requirement_Specification.docx

View 1 Replies View Related

Msg Box To Create New Workbook

Aug 24, 2008

way to create a msg box with if you click "yes" it will copy the data from sheet 4 on workbook 1, and paste it onto a new workbook that is a copy of a standard template of workbook 1, and rename it based on a file name you give it.

ex. Pro Shop Template

Workbook 1 is Pro Shop 9/08-10/08

New Workbook 2 is a copy of Pro Shop Template but names Pro Shop 10/08-11/08

View 9 Replies View Related

Add-In To Create A New Workbook In Same Folder

Sep 9, 2008

Is there a way of creating a new excel workbook using a macro that is stored as an Add-In.

The new workbook is to be created in the same folder. If I use the following command in macro then it saves the file in the Add-In folder.

View 14 Replies View Related

Create Summary Workbook

Jul 10, 2009

I need a macro that will copy and paste the data from the range below from every file in a directory with each file in the directory on a new row. My goal is to build a database with the information in the files in the directory. I will need to be able to put the directory in the code at a later time as it has not be set up yet. it will be on the local computer and not on a network share.....

View 8 Replies View Related

Create New Macro In New Workbook With VBA

Apr 30, 2013

Is it possible to create a new workbook, add a macro to it, set it to run as an auto open event and then save and close the new workbook?

To explain a little better, I have a macro in a workbook. This workbook is opened by Filemaker which triggers the macro to run. The macro creates a number of different workbooks using information from an online file dump which is then imported into Filemaker.

However when the import is finished, I'd love for all the files that have been created to get deleted again. Now I realise I could just create a second workbook that Filemaker opens once the import is finished that deletes all the files. However I want to keep things as simple as possible for the user, and for them to have as few files as possible so things are less likely to get misplaced in the future. My concern is as they never see the workbook macro firing, they won't realise how important it is, even if I make it very clear.

So what I was thinking is at the end of the first macro, it creates another workbook, with an auto open event macro in it that simply calls a macro from the original workbook, and once created it is saved and closed. When Filemaker is finished with it's import, it could then open the new workbook which calls the macro in the original workbook. I could then have the original workbook macro delete all the added files, and close and delete the other macro enabled workbook it created. Which would leave me with the original workbook only.

View 3 Replies View Related

How To Create Cash Up Workbook

Apr 15, 2014

I am new to macros on excel but I am trying to create a cash up workbook. This is what I want it to do:

First Sheet should be a summary of the month with each day. From there I want it to generate 4 worksheets for every day's cash up. (which should be Daily Cash up, Credit Card Sales, Cheque Sales & Account Sales).

The Daily Cash up Sheet must pull info from the other 3 and must allow me to input cash values manually. But the cc sales, cheques sales and account sales must be pulled from the other sheets.

After completion of cash up there should be a button on the Daily cash up sheet to say Finalise, where when it is pressed it summarises all totals on the first sheet. So when I open the workbook every morning, there should be a button on the first sheet to create a new 'cash up'.

Then there should also be a button on the first worksheet for month end, so that when you press month end it finalises the month and generates a new work book for the next month.

View 7 Replies View Related

Create Macro That Can Be Used In Any Workbook?

Jun 11, 2014

I would like to create a macro (with button) that can be used in any workbook. I tried creating a macro in a blank workbook and added a macro button to the Quick Access toolbar. It shows up in any workbook I have open BUT when I run the macro, it also opens up the blank workbook.

View 1 Replies View Related

Macro: Create A New Workbook

Feb 17, 2010

I've created what I thought was going to be a simple macro which will create a new workbook, rename it "Applications Calls", then copy a pivot table/report from another workbook and paste it. Here's my rather amateur code which doesn't work.

Sub copyreport()
Workbooks.Add
ActiveWorkbook.Name = "Top Ten Apps Calls.xls"
Windows("Applications Calls Logged North.xlsm").Activate
Sheets("Calls Logged by Customer").Select
Cells.Select
Selection.Copy
Windows("Top Ten Apps Calls").Activate
Cells.Select
ActiveSheet.Paste
Range("A16").Select
ActiveSheet.PivotTables("PivotTable5").PivotSelect "Silo", xlButton, True
ActiveWindow.DisplayGridlines = False
ActiveWorkbook.ShowPivotTableFieldList = False
Range("A16").Select
End Sub

View 9 Replies View Related

Create A Help Section In A Workbook

Aug 5, 2003

I want to include a help section in a workbook I created. I need something more than just a MsgBox ;-)

I'd like it to be like the windows' help that you have everywhere.

View 9 Replies View Related

Create Standard Workbook

Nov 28, 2007

I am fairly new in Macros, I have a workbook wich will have some data for each year month, the new month ( sheet) data will be added by a macro, copying the current sheet (month) as a base. When all months are created I need to create new workbook with only Jan (January) sheet. I created the following macro, but I think it could be reduced, in code lines, and need to how to create the new workbook based in last (December) sheet.

Sub AddSheets()
Dim wSheet As Worksheet
SheetName = ActiveSheet. Name
Select Case SheetName
Case "Jan"
On Error Resume Next
Set wSheet = Worksheets("Feb")
If wSheet Is Nothing Then
'Add Sheet Code
Sheets("Jan").Copy After:=Sheets("Jan")
ActiveSheet.Name = "Feb"
Sheets("Feb").Select...................

View 3 Replies View Related

Create New Temporary Workbook

Jun 17, 2008

I'm trying to create a new worksheet just in memory.

Private Sub test()
Dim wsheet As New Worksheet
Dim a As Variant
a = ActiveSheet. Range("A1").Value
wsheet.Range("A1").Value = a
End Sub

When I run this, the like "wsheet.Range("A1").Value = a" gives the error <Class does not support automation or does not support extended interfaces. I could use that vitual worksheet (I call) to do functions like sorting filtering and other things without affecting the actual data, and get only the results. Is there a way to create such virtual worksheets.

View 6 Replies View Related

Macro To Create New Workbook With Name Other Than Book1?

Oct 28, 2008

I'm tryign to create a macro which will copy certain worksheets into a new workbook (i.e. Book1), and the macro continues to work with this Book1. Is it possible to create a more robust macro which will rename Book1 into something usable (i.e. "Report")? because if the session of Excel has already had another worksheet, it will go to Book2, and then the macro won't work.

View 5 Replies View Related

Copy Range :: And Create New Workbook

Oct 19, 2009

I have a currently working macro to copy the current sheet as values and create a new workbook in the same folder destination. That code is as follows:

View 10 Replies View Related

Macro Will Not Create New Worksheet And Workbook

Oct 28, 2009

Im trying to create a document that creates a new workbook when certain functions are selected and have written a macro to assist with this. Basically im working on a comprehensive checklist with all possible scenarios that will need to be tailored for use, so you can create a document with just what is applicable to you and not the whole checklist. I have attached a sample of what i mean, along with clearer descriptors of what the document is designed to do.

View 5 Replies View Related

Create Statement From Cells In Workbook

Jun 2, 2008

if it's possible to create a statement from cells in a workbook perhaps by using the hyperlink option or if there is any other alternative way.

In brief, the statement should recognise what has been inserted into each cell in the row and then generate a statement.

I hope this is clear. See attached a copy of the excel sheet from which I would like to create the statement.

View 9 Replies View Related

How To Create Array Of All Sheets In WorkBook

Nov 11, 2011

Sub Macro2()
Dim stgSheets As String, Cnt As Long
Dim arrSheets()
Cnt = Sheets.Count
ReDim arrSheets(Cnt - 1)
For i = 1 To Cnt
stgSheets = stgSheets & Sheets(i).Name
arrSheets(i - 1) = stgSheets
'sSheets = sSheets & "", ""
Next i

[Code]...

View 2 Replies View Related

Create And Save Workbook In Folder

Apr 27, 2013

I want to write a piece of code where each day i run this code

I want add a workbook

Copy range ("A1:C5") to this new workbook

Save new workbook in a particular folder with the name customer data and todays date and save as CSV file

I run this this code every day so it should only add todays date at the end for filename

If for some reason I run this code again in the same day..

I want to have a msgbox stTing you have already ran this code today and exit sub

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved