Save Single Sheet To New Workbook And Delete VBA Code From New Workbook

Jun 25, 2014

I'm trying to find a way to save a single sheet of an excel workbook and in the same process delete all vba code and shapes from the new single sheet workbook. I was looking around and found this code which does save only the single sheet to a new one sheet workbook but doesn't delete the vba and shape that I have used to assign macros to in the original.

Code:
Sub SaveSheetAsNewBook()
Dim wb As Workbook
Dim InitFileName As String
Dim fileSaveName As String
Dim wshape As Shape
InitFileName = ThisWorkbook.Path & Format(Date, "mm.dd.yy")

[code]....

View 2 Replies


ADVERTISEMENT

Save A Single Sheet In A Workbook Using A Macro

Apr 2, 2009

I need to save a single sheet to a file (in a workbook of many sheets). I can't use the copy command and then save the new workbook because it truncates the longer info in some cells.

View 9 Replies View Related

Excel 2007 :: Generate Single Sheet Workbook And Save To Sharepoint Site

Jan 4, 2012

Automating Excel from Access, I'm attempting to generate a single sheet workbook and save to a Sharepoint site. This process works fine on my machine (XL2007, XP), but on a coworkers computer (XL2003, XP), the code throws a 1004 error on the save as line. However, the really odd thing is that stepping through the code doesn't throw an error on the coworkers machine.

Here's the sub being ran; the line it errors out on is the first branch in the .saveas block.

Code:
Private Const csSharePointSaveAs = "\sharepoint-us.mycompany.comsitesfinance adminlah blahlah-blahCustomer Publication Tracking.xls"

Private Sub PublishXLtoMOSS()
Dim objXL As Excel.Application 'Object
Dim wb As Excel.workbook 'Object
Dim ws As Excel.Worksheet 'Object
Dim rs As DAO.Recordset
Dim i As Long

'Set objXL = CreateObject("Excel.Application")

[Code] ...........

View 1 Replies View Related

Code To Copy Data From Dif.cells In A Sheet To A Single Row In Another Workbook

Mar 3, 2008

I have a workbook ("CaTr") Sheet1 has data ranging ("B2:I41").

There are about 30 cells values (scattered) which needs to be copied in a workbook "CA_Log" in one single next available row .

As soon as the CaTr.sheet1 is filled I want the operator to click a button to trigger this event. Then the sheet1 in workbook CaTr should be saved as "G3" cell value.

View 14 Replies View Related

Macro To Copy Dynamic Sheet In New Workbook - Save As Temp / Mail And Delete

Sep 15, 2014

Code to copy the sheet that get selected by if-then-elseif statement and paste in a new workbook, save the workbook as temp, email it and delete it,

sub sending_mail

Dim OutApp As Object
Dim OutMail As Object
Dim rng As Range
Dim DataWB As Worksheet

[Code] ......

View 2 Replies View Related

SaveAs - Copy Sheet Into New Workbook And Save It In Same Folder As Original Workbook

Jun 17, 2014

I have been trying to edit a code which previously saved a copy in a new workbook to a specific folder/path. (Additionally it copies and clears some figures, but this is working as it should.)

However I would like the copy to be saved at the same location as the original workbook, regardless of the path the original workbook is saved.

I.e if I need to move the workbook containing the code to a new folder/location, when using the macro, the new copy should be stored in the same folder/location as the original one.

For now it is only saving the copy into "My Documents"

Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 16-02-2009 by ceng
'

Sheets("Bunker ROB").Select
Sheets("Bunker ROB").Copy
ActiveWorkbook.SaveAs Filename:= _
ActiveWorkbook.Path & Range("D3"), _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

[Code] ........

View 2 Replies View Related

Save A Single WorkBook Tab To A New File

Aug 28, 2008

I am using Excel 2003 and need to save via VBA code a single tab in a workbook to a new workbook. I need to be able to specify the new workbook file name and location. The copy feature on the tab won't work because the data is too large and I get an ugly message using that option.

View 9 Replies View Related

Delete Original Workbook After Save As

Mar 21, 2008

I don't believe this is possible but I've been wrong before.. Is it at all possible to Kill the current workbook using VBA? I " saved as" in another location and do not wish to keep the current workbook.

View 3 Replies View Related

Have Code To Block Save But How To Keep Code In Workbook Without Saving The File

Aug 1, 2013

My company has files that are already in use. I don't know too many details about how they work, but somehow saving the file will screw it up and my boss has to go back and reset something or other to correct it. Obviously it's connected to some other software somewhere. The code below will block Save and Save-As. BUT how do I get the file to hold onto the code without actually saving the file after the code is added (since the file shouldn't be saved)?

VB:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI = False Then
Cancel = True

[Code].....

View 1 Replies View Related

VB Code To Save Workbook

Feb 24, 2009

I have a code that saves my worksheet once it closed. At the moment it saves the Active worksheet which is Sheet1

The problem i have is i have a few vlookup formulas that reference hidden worksheets Sheet2 & Sheet3

Would it be possible to modify this code so it saves the entire workbook?

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
Dim bk1 As Workbook
Dim bk As Workbook
Dim myfilename As String
myfilename = "C:files" & Range("B10") & " - " & Range("J10") & ".xls"
Set bk = ActiveWorkbook
Set bk1 = Workbooks.Add(Template:=xlWBATWorksheet)
bk1.Worksheets(1).Name = "Sheet1"
bk.Worksheets("Sheet1").Copy _
bk1.Worksheets("Sheet1")
On Error GoTo 0
bk1.SaveAs Filename:=myfilename, _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWindow.Close

End Sub

View 9 Replies View Related

Using VBA Code To Save A Workbook

May 17, 2006

is it possible to use code to save a workbook? I know this is pretty basic, but for the life of me, I cannot answer this question searching the entire website and forums.

I'm currently creating what could be called a "yearly timesheet" for a small company and trying to automate it as much as possible. I've created several buttons along with input boxes to create the data, now I would like to make two more, one to save the worksheet (preferrably using data from one cell as the workbook name) and a second to send the workbook to the local, default printer. I've come across the topics on stopping Excel from automatically asking the user to save it, etc etc but none along the lines of "this is how you create a button that if clicked, saves the workbook."

View 9 Replies View Related

VB Code To Email Single Worksheet Within Workbook

Jan 27, 2009

I need a code to be applied to a VB button that will email out a selected worksheet within the workbook, lets say i need to email out sheet5. Is it possible when the button is clicked to bring up my email client, (it's not Outlook) with the file already attached so i just need to add the email address/adresses?

View 9 Replies View Related

VBA Code So User Cannot Save Workbook

Oct 11, 2013

I have a workbook that is shared between 10 users and this work book is known as Master, what I don't want to happen is for one of the users to over write and save it. So is there a way one not allowing the user to save but allow the user to save as.

View 2 Replies View Related

Save Workbook As CSV Macro Code

May 19, 2008

I want is a Macro that will save the file as .csv, with the same filename and location as the original (just in csv format). A hotkey would be quite handy for this. I tried using the macro recorder and fiddled around with the code a bit but my programming knowledge is quite limited and I ended up with something that doesn't quite work as i'd like. I'm sure this would only take a few seconds to code for an experienced user, which is why I post here. I would post my attempt at doing it myself but i'm on a computer that doesn't have excel at the moment.

View 3 Replies View Related

Email A Single Sheet From A Workbook

Sep 30, 2009

I have a spreadsheet that has approx 10 different sheets (tabs at the bottom). I want to write a routine that will take one of the sheets, copy it to a new workbook, and email the newly created workbook using Outlook.

I've entered this question once before and got some suggestions that seemed to work for a while. Then it became hit and miss as to whether it worked or not. Now I'm geting a "Can't create object" error everytime. I want to break this one sheet out and send only it because I don't want to send the entire workbook.

View 4 Replies View Related

Workbook Save Not Working With Basic Code Included?

Feb 26, 2014

I am attempting to save a workbook when it opens, but when the code is run, it is not saving. For the purposes of finding the problem with the code, I have simplified it down to the following:

Code:
Private Sub Workbook_Open()
Range("C3") = "HEY"[code]......

View 8 Replies View Related

Create Multiple Workbooks From One Single Workbook Based On Customer Code?

Jul 6, 2008

I have an excel file which contains following data in it.

Col-A Col-B Col-C ......
Cust Cd Name Sales
=======================
101 AAA 1000
101 AAA 500
101 AAA 3000
102 BBB 800
102 BBB 200
103 CCC 200
103 CCC 200
103 CCC 200

I need to create following three workbooks with name based on Cust Cd from above excel file.

Workbook - 1 : 101.xls which contains records only pertaining to Cust Cd 101.

Workbook - 2 : 102.xls which contains records only pertaining to Cust Cd 102.

Workbook - 3 : 103.xls which contains records only pertaining to Cust Cd 103.

View 4 Replies View Related

Error Emailing A Single Sheet From A Workbook

Oct 13, 2009

I have an original workbook that I use daily stored in a folder called 'Live'. I also have this same workbook saved in a different folder call 'In Progress' because I am constantly improving and making changes to it. While I'm in the revision mode, I keep it in this folder. Once I've completed my revisions, I move it to the folder where the live workbook is located and replace the old version. Therefore, I have two copies of the workbook at all times. The name of the workbook in both folders is the same (IRQT)

I have a macro in this workbook that will allow you to save a copy of the workbook in a folder called IRQTArchive. The macro will create the folder if it doesn't exist, then store a copy of the workbook using a name in a cell. After that is complete it renames the workbook back to the original name (IRQT).

This macro works perfect in my live version, but when I execute the macro in the 'In Progress' version, I get a Compile error: Sub or Function not Defined when it reads the dirExists command in the first line of code. The code in both sheets is identical. Here are the first few lines of code. The command dirExists is highlited in yellow when it errors out.

View 11 Replies View Related

Creating Multiple Sheet In Single Workbook

May 3, 2014

I have a My.xlsx file that has data for single month and I want to make a single file in which I can have contents for whole year by copying this file 11 more times in the same excel work book. Finally I would have 12 sheet in a single workbook.

E.g. Jan-14, Feb-14, .... ,Dec-14

I don't need any calender data just 11 more copies of my original sheet in a single work book.

View 3 Replies View Related

Copy Single Call Value From Multiple Workbook To Master Workbook

Sep 17, 2009

I have multiple workbooks ( with unique names) under same folder. Each workbook has "Report-Corn" sheet.

I would like to copy cell "P15" from each (workbook-> report-corn -> P15) and paste to Master.xls workbook -> Sheet 1 one after another which is also located under same folder.

View 9 Replies View Related

Single Sheet SaveAs Without Changing WorkBook FileFormat

Feb 25, 2009

I wish to save a single sheet from a multi-sheet workbook as "xlTextPrinter"
to do this I use:

View 4 Replies View Related

Selecting A Single Sheet From A Volume Of Sheets In A Workbook

Jun 30, 2006

I have 30 and above sheets in a work book and like that I am having 5 such
books. The sheets are named as 201, 202, 203 ....etc as per the contents in
that particular sheets. (201, 202 .....are the P.O nos.). all the work
sheets are of having similar format of datas.

Now what I need is if I want to look the details of one single sheet (say
324) I have go all the sheets one by one and it is hard to find out.

If any body give me a solution so that if I type a particular no. (forms
part of the name of the sheet) that sheet should appear for me.

View 12 Replies View Related

How To Call All Data In New Workbook Or In Single Sheet From Different Sheets

Dec 28, 2011

Call all data in new workbook or in single sheet from different sheets (except 1 or 2 sheet) of workbook. i already use some macro to hide some data from sheets so i want only filtered data.

View 8 Replies View Related

To Consolidate Data From 2 Or More Sheets To A Single Sheet Within A Workbook

Feb 1, 2009

I have 2 sheets which validates data using vlookup.

Sheet1

Table 1ABResult1121232313

=VLOOKUP(A7,B:B,1,FALSE) is the formula in result1 column.
Sheet 2

Table 2DEResult21020102040203010#N/A

=VLOOKUP(F7,G:G,1,FALSE) is the formula in result2 column.

The basic idea of these vlookup is to check whether the data present in A or D column is present in B or E. If the data is there then it will be retrieved in "Result1" or "Result2" columns. If not then the result would return the value "#N/A".

What im trying to do is to copy the resultant data(from Result1, Result2) other than "#N/A" from individual sheets to a final consolidated sheet.

View 9 Replies View Related

Save Active Sheet To Another Workbook

Nov 3, 2008

Copy the active sheet that is open in a work book and save it to another file with the date in the name? For example Report_11-03-08.xls

The only problem I see with this. How could I also make it append a letter to report if the file already exits Example saved as
Report1_11-03-08.xls. Then just continue incrementing.

Sub CopySave()
Application.ScreenUpdating = False
ActiveSheet.Copy
Application.DisplayAlerts = False
ActiveSheet.SaveAs Filename:=ThisWorkbook.Path & "/" & "Report_" & Format(Date, "mm_dd_yy") & ".xls"
ActiveWorkbook.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

View 5 Replies View Related

Save Active Sheet Of A Workbook In VBA?

May 17, 2005

How can I save only the active sheet of a workbook in VBA?

View 9 Replies View Related

Copy Columns From Multiple Sheets To Single Sheet In Workbook?

Aug 11, 2012

I have a workbook with many sheets labelled as mmm-yyyy. The constant columns in all the sheets are C,E,R,T, and U.

Is it possible to have a macro do the following: Add a sheet called Summary at the end of the workbook. From the last sheet of mmm-yyyy, copy columns C, E, and R to the Summary sheet. Copy columns T and U from all the other mmm-yyyy sheets to the Summary sheet. All the cells need to be centered.

View 3 Replies View Related

Print Entire Workbook + Multiple Copies Of Single Sheet

Apr 16, 2009

This is probably a VBA thing, but there might be a simpler solution. Either would be grand!

Basically, I have a four sheet workbook that needs to be printed out in its entirety (no problem doing that ); however, I would like the final sheet (called "Room Data") to be printed, let's say ten times.

So basically I'd get a single print of the first three sheets and ten of the "Room Data".

Any ideas on how to do this without having to manually print the final sheet multiple times or creating ten identical sheets in the workbook?

View 3 Replies View Related

Save Excel Sheet In PDF Format With The Name Of Workbook

Jun 23, 2012

I have the below macro steps to save an excel sheet in PDF format in "C:UsersxxxxxDesktop" and with the name of the workbook.

But when the PDF report gets published in c: drive , the PDF file name has .xlsm added to it instead of just the file name.
I would like to know how to publish the file in PDF format just in the name of the workbook.

Find the below macro steps:

Sub Docsave()
Dim docname As String
docname = ThisWorkbook.Name
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:UsersxxxxxDesktop" & docname, Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:= _
True
End Sub

View 1 Replies View Related

Save Sheet Then Continue From Active Workbook?

May 5, 2014

I got a workbook with a database in sheet1. I filter that database and copy - paste values the results to a new sheet. Next, I save that new sheet to somewhere on my drive. The thing is that I want to go back to my original database, and continue filtering. But that workbook is no longer the "active workbook". This is how it works:

sub DifferentClients()
For Each FieldWorkBy In Array("Client1, Client2,...")
MyDatabase.AutoFilter Field:=CountryCode, Criteria1:=Array( _

[Code]....

View 3 Replies View Related







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