Save CSV As New Copy & Delete Original
Apr 20, 2008
I was wondering if it is possible to have a macro running that will automatically save a .csv file to specific location and close the file. I would like to have the macro running so that as the files are opened they will be automatically saved to this location.
View 2 Replies
ADVERTISEMENT
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
Aug 27, 2007
I'm trying to save a copy an excel file in the same directory of the original file. The code is pretty standard but it does not work if the file is stored in C: (only c: ) Is that a bug or am I doing something wrong? Anyways here is the code in case someone is interested in trying it out:
Sub CreateCopy()
ChDrive ThisWorkbook.Path
ChDir ThisWorkbook.Path
fileSaveName = Application.GetSaveAsFilename( _
fileFilter:="Excel Files (*.xls), *.xls", _
InitialFileName:="CMS_" & Format(Now(), "mm-dd-yyyy"))
If fileSaveName <> False Then
MsgBox "Backup copy saved as: " & fileSaveName
End If
End Sub
View 5 Replies
View Related
Jun 14, 2008
I want to have a user press a button on a worksheet page to save a copy of the workbook (and be able to name it and choose where to save it to) without closing or modifying the original. Note that if you "save as" manually it renames the workbook and closes the original.
View 7 Replies
View Related
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
May 7, 2013
How does one do a save with a new name while keeping the original file intact - with the original file name? Would a macro be required?
View 1 Replies
View Related
Aug 27, 2008
I have VBA program that collect the data from database and make a report.(I will mention I open the browser to look for database )
Here is a problem:
My original file is " Daily Report.xlt(template) " .At the begin when I open this file ,the file name appear as a " Daily Report1 "...This is not big deal
When I run macros I need to keep some info on the original file.
After I done, I have following code to save as " Daily Report.xlt " .
but the actual problem is ;the code save this file on the database path that I don't want it.Actually I want to overwrite on original file to keep that file up to date.Here is code
ActiveWorkbook.SaveAs Filename:= _
"Daily Report.XLT", _
FileFormat:=xlTemplate, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Note:I know I can add the path in front of the file name and save it in the that directory .Different customer different path I can not use fix directory.
View 9 Replies
View Related
May 14, 2009
I am trying to sort a macro out to save my sheet the same as the original when the button is clicked. When i try it from one location it is fine but from another location i get a print error, the error says prit quality is not right, when i debug it highlights: Print Quality = 600 I have tried changing it but keep getting the same error. Their maybe an easier way to do this but not being very good on VB i dont know what to do. This file is on a server and will be accessed from different locations.
View 2 Replies
View Related
Jun 21, 2006
I am writing a macro that copies a pdf from a temporary directory to a permanent directory. After the copy is complete, I want to delete the original file. Looking in Visual Basic Help, it appears that I need to create a FileSystemObject, but I have no idea what that means or how to do it. sDirectory is a string variable of the path of the file and sBatch is a string variable of the name of file. This isn't working.
Set fs = CreateObject("Scripting.FileSystemObject")
sDeleteFile = (sDirectory & sBatch)
Set a = fs.CreateTextFile(sDeleteFile, True)
a.DeleteFile.sDeleteFile
View 4 Replies
View Related
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
May 25, 2014
My worksheet that will have duplicate data inserted into it. Once inserted I need to delete the new duplicate row and the row it duplicated. The attachment is a copy of what the data looks like with the first tab showing what it will look like with inserted data and the second tab is what I want it to look like at the end. I will not need the deleted data again so it does not need to be on a new sheet, that is just for an example. The name of the tabs will also be different so I want to be able to run it on any worksheet. This is the code I am using to find and delete the duplicate but I can't get it to delete the original. I used "First, MI, Last, and DOB" because those are the ones that won't be duplicated where others will. This is a list of about 15,000 entries. There should never be an incident where there is triplicate data but I can't say for sure.
[Code] .....
Attached File : Practice.xlsx
View 2 Replies
View Related
Sep 8, 2009
i would like to be able to move files from one folder to another then delete the original files.
I dont think im passsing the variables to the functions corectly.
View 8 Replies
View Related
Jan 15, 2010
I have a large worksheet with over 8,000 rows and about 5 columns. In several instances, I have several rows that are all exactly the same. It could be 2, 3, 4 or even more rows that are duplicate to one another.
I would like a macro that deletes ALL rows that are duplicates, including the original.
For example, let's say, rows 3, 4 & 5 are all exactly the same, I don't want to just delete rows 4 & 5, I want to delete row 3 as well!
View 9 Replies
View Related
Mar 18, 2008
I am trying to create a way to easily maintain a list of outstanding checks. I am able to import cleared checks into the spread sheet but cannot find a way to compare the two lists and then delete the cleared checks off the original list.
View 2 Replies
View Related
Sep 5, 2012
The problem is when I highlight a row with some color the original color of the row is gone, so I tried this code, and again, it's removing the original format and color for the row This is the code from McGimpsey & Associates : Excel : Highlight row with background colors
Code:
PrivateSub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Const cnNUMCOLS AsLong=256
Const cnHIGHLIGHTCOLOR AsLong=36'default lt. yellow
Static rOld As Range
Static nColorIndices(1To cnNUMCOLS)AsLong
Dim i AsLong
IfNot rOld IsNothingThen'Restore color indices
[code].....
How can I retain the range's historical color so that when I deselect the row it reverts properly?
View 4 Replies
View Related
Mar 14, 2014
I have a macro which successully saves a worksheet as new file to another file path....(below)...but I can't figure out how to close this new file and return to the original file...
Dim myPath As String, fName As String
myPath = Sheets("Date").Range("C8").Text
fName = Sheets("Date").Range("C9").Text
Sheets("Sage CSV File").Copy
With ActiveWorkbook
.SaveAs Filename:=myPath & fName
End With'
View 2 Replies
View Related
Oct 15, 2012
I need to copy the sheet being worked on, and place it behind the original sheet.
This is going to be in a Macro enabled template that other users will be rename when they save it.
It will be activated by a button on the original worksheet other users may need to rename the worksheet before copying so I am using ActiveSheet.Copy I don't want to put the sheet after a counted sheet, because other sheets may be inserted before the one being worked on. I am not proficient at VB, I basically search for a macro that does what I need and copy it.
This is what I am working on.
Sub CopySSR()
'
' CopySSR Macro
'
'
ActiveSheet.Copy After:=Sheets(7)
End Sub
View 2 Replies
View Related
Sep 27, 2008
A simple one for you, but again my Google skills seem lacking. This must be common practice but until one knows the key combination...
I have created a summary sheet with lots of formulas which analyse other sheets in a workbook. I want to copy this summary sheet to a seperate workbook to use as a template.
Of course, the copying process always links the new (template) sheet to the original workbook it was copied from. How does one copy without forging this link? All I want are the formulas copied across totally unchanged; I really *don't* want to manually edit 50 or so formulas!
View 7 Replies
View Related
Dec 3, 2007
I would like to create a copy of an open workbook.
Workbook.SaveAs would seem to be a possibility, but this closes the original workbook - I need to keep the original workbook open as well as the workbook it has been "SavedAs".
I do not want to close the first workbook and repoen it as there are instances where it may be protected and I do not want the user to have to reinput any passwords etc.
View 9 Replies
View Related
Mar 1, 2004
I have a CSV spreadsheet full of data: many rows and many columns. I want to sort based on values in some column. Then, I want to divide my large worksheet into smaller worksheets based on these sorted column values. For instance, if column 4 was 20,000 items long and contained 6 unique values I would want to create 6 smaller spreadsheets. Each spreadsheet would still have a column 4. Now, however, all the column 4 values would be the same for a particular spreadsheet. It would be nice to have a pop-up window query me for which column to use to divide the data with, instead of hardcoding a value in (like 4).
I am trying to crank this CSV file through MATLAB and it is just too big. My PC has 1GB memory and it still craps out. I am guessing that a dozen or so smaller files will be easier for MATLAB to digest. Any help is appreciated!
For the record, I am doing the following to sort a column, then copy it to a scratch worksheet and then determine all the unique values. I have hardcoded in column lengths and would really like to know how to make these variable expressions:
Sub divide_and_conquer()
Dim lngSheet As Long
Dim strName As String
Range("A1:HR778").Sort Key1:=Range("D2"), Order1:=xlAscending, Key2:= _
Range("B2"), Order2:=xlAscending, Key3:=Range("E2"), Order3:=xlAscending _
, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _.............
View 9 Replies
View Related
Aug 11, 2007
I have some code written to duplicate a template and rename the copy to "Working Copy".
But if I run the code more than once, it breaks as VBA tries to overwrite the sheet with the same name.
Would I would like is for the macro to check to see it already exists and duplicate the copy with some type of incremental integer. Thus the first duplicate would be Working Copy 1, and if the macro is run again, the duplicated copy would be Working Copy 2, etc.
here is what I have so far:
Sub SCButton()
Dim i As Integer 'for making Working Copy 1, 2, etc.
Sheets("SCTemplate").Select 'this file will eventually be hidden and thus the user with only see the wokring copies.
Sheets("SCTemplate").Copy After:=Sheets(4)
Sheets("SCTemplate (2)").Select
'some sort of If statement here to check for the sheets
Sheets("SCTemplate (2)").Name = "Calculation"
View 5 Replies
View Related
Apr 15, 2014
At my work we are using Excel as a CMS to produce SQL scripts for insertion into a database. The data is then turned into mobile web pages. This involves multiple workbooks - 1 for each main page with the sub-pages as extra worksheets in the book.
Much of the data is duplicated so we have created master workbooks then copied them and laboriously referenced the relevant cells back to the original. That way if any data in the master is changed, all copies will change simultaneously.
This is obviously not the most efficient way of publishing web pages but we are stuck with it for now. So I am wondering if it is possible to write a VBA code to create a copy of the master and then reference all required tables in the worksheets automatically? The tables are all named ranges.
View 9 Replies
View Related
Dec 19, 2013
I have attached a copy spread sheet. This has been working great but i have been asked to add some items and i dont want to screw up the working functions.
I now want to add incert two columns so the actual costs of a first and second service can be added to the contracts and used contracts sheets, this information allong with data from a,b,e,g h needs to be copied over into a new sheet (report sheet) which will have the budgeeds costs in column i,j starting from row 3 and finding the last row so as not to overtype so that a report can be sent showing profit/loss.
The costs will be put in at diferent times so it only need to up date a changed cell
If i just add columns will this effect the auto archive coding? Could the data be copied over to the new sheet using the original code on start up? (so customer etc copied then as cost are put in these would be added to the respective rows on each start up.
I have had to remove some of the sheets to up load this so my not work correctly, but you can see the funtion in the code
View 3 Replies
View Related
Feb 17, 2009
I'm trying to create a VBA macro that will allow me to copy a formula from one sheet to another whilst keeping all the original references.
E.g.
If the formula on Sheet1 is:
= sum(A1:B6)
then the copied formula on Sheet2 would read
=sum(Sheet1!A1:Sheet1!B6)
You can do this by cuting the cell, but I don't want to do this, I want to leave the original cell unchanged.
I'm sure there is some simple VBA code to do this, but I can't seem to figure it out.
View 9 Replies
View Related
Feb 11, 2009
I need to copy the Selected Sheet (Sheet name will be different each month) on a spreadsheet and paste the copy to the left of the selected Sheet. Then I need to copy and paste values the entire sheet of the sheet that the copy was made from (the one on the right). I am very new to macros, and I tried recording and manually editing the macro with no success. The number of sheets will be different always as I will be adding this to different workbooks and also because new sheets may be added to any workbook at any time. I attached my code that I came up with, as I am not familiar with code enought to "[code]" my code.
View 3 Replies
View Related
Nov 20, 2012
Wanted to know if there is a macro that can copy the selection of cells and paste it as a formula with original cell refernce.
For Example :
Copy Selection Cells - Say Cells A1 B1 & C1
and Paste It as formula In Cell D1 as =A1+B1+C1
View 7 Replies
View Related
Apr 3, 2014
In my excel I'm copying rows upon specific criteria to another tab.
The question is how I can delete copied rows and update the original tab without empty rows? (N of rows is always changing)
View 14 Replies
View Related
Nov 12, 2009
I'm trying to find a way to search a second sheet in a workbook for specific criteria outlined in a first sheet (in my attached example, from A3 downwards within the 'list of search criteria' sheet), and then to copy any secondary data found against a successful search match to the original sheet, transposed against its corresponding matched search term.
As you can see in the example, the search term 'bindi' (A4 in the 'list of search criteria' sheet) appears in the 'data' sheet 3 times - the secondary data for these occurences ('feathery', 'Fibonacci', 'glassy') is copied to the 'bindi' row on the first sheet and is offset with each copy to produce a transposed-esque effect of copy and paste.
If it's any help, there are a maximum of 9 matches for a single search term in the real document.
Thanks in advance for your help... I tried to adapt a previous solution given to me for a similar question but failed miserably. I bow humbly to your expertise!
View 9 Replies
View Related
Mar 27, 2008
I have a sheet which I would like to back up online every time it is saved.
I have a sub, OnlineFile(), which I have used many times without any problems, which creates a .BAT file to use ftp to upload files onto our server. As arguments, it takes the local file path that you want to upload (or download to), the name of the file as you would like it stored, the online file path, and whether you want to upload the file onto the server, or download it off the server.
It should be very easy to combine the two: what I tried was:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, cancel As Boolean)
ThisWorkbook.SaveCopyAs ThisWorkbook.Path & "" & "Rubbish.xls"
Call OnlineFile(ThisWorkbook.Path & "" & "Rubbish.xls", "Rubbish.xls", "wwwrootexcelfilesMasters", "Upload")
Kill ThisWorkbook.Path & "" & "Rubbish.xls"
End Sub
Every time I ran this, the file got uploaded correctly, but Excel had a series of problems. Often the code ran fine the first time it was run, but crashed the second time round.
After a fair bit of troubleshooting, I found that the problem came about when the file was trying to save itself - i.e. after the end of the sub. If you pause any macros from running, it still saved fine, but when the code ran, it found errors, froze or closed excel.
My thought at this point was that the code was fragmented or something. I made a new sheet, and retyped just the relevant bits of code (i.e. the BeforeSave sub, the OnlineFile sub and created the form called by OnlineFile). The problem persisted.
I've come up with a workaround for this now (which uses the same OnlineFile sub & form, and works fine), but it's driving me crazy - why does this cause excel to die? Particularly on the second time through? The code seems far too simple to cause such problems - is there a bug in Excel perhaps (I'm using Excel 2000 on Windows XP).
View 9 Replies
View Related
Sep 5, 2007
I have copied and then pasted & linked numerous cells from one sheet to another within the same workbook. When I copy the 2 sheets (Edit>Move or Copy Sheet>Create Copy) the linked cells on the duplicates remain linked to the original sheet. How can I copy the 2 sheets and have the cells on the copied sheet be linked to the copied sheets and not the original?
View 4 Replies
View Related