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
ADVERTISEMENT
Sep 8, 2006
Read “My Documents” Path And Use Result
Problem:
Note:
Typical user OS will be Windows XP Pro / Win 2K
Excel version : 97 / 2002 / 2003
1. Corporate network security settings will only allow directory/subdirectory creation in the “My Documents” section of customers individual computers.
2. Per customer request, VBA application needs to save extracted files for future use.
3. I can specify an initial “My Documents” subdirectory be made and the VBA application file be loaded/copied into that location – i.e. – “My DocumentsCat”.
4. When VBA application is opened from that specified directory, (first time), the application needs to make an additional subdirectory tree to save future files. I can read the opened from location via VBA with the following:
Dim filepath As String
filepath = ThisWorkbook.Path
As an example – this code would produce a string definition of “filepath” – such as the following:............................
View 5 Replies
View Related
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
May 20, 2009
I need save my workbook as copy to another directory, ( C: ) with VBA code
View 9 Replies
View Related
Feb 23, 2010
I am continuing to struggle with my first attempt at a macro, and wonder if someone would mind taking a look to see where I have gone wrong? All I am trying to do is create file copying tool where the user can define the source and destination directory in workbook cells, and assign the macro to a button to complete the copy of all files from source to destination.
The macros do this:
Source and Location directory defined in Sub Archive1.
These are passed to file copy macro Sub ArchiveScript.
This macro checks for presence of destination directory, ensures that the directory backslash is in place, specfies the variables fn and fn2 to make sure the filecopy command copies all files in the directory, and then carries out the filecopy function itself.
However, I am getting two errors from the code that I can't figure out (I am still very much a beginner!)
- Invalid procedure call or element on fn = dir() at the bottom
- The copy still works, but only seems to copy one file from the source to the destination, and not all of them.
View 6 Replies
View Related
Nov 23, 2011
I am trying to query our corporate directory to copy it into excel. The problem is that the table i want to copy has 90 pages. I do not know VBA very well at all. Is there code that I could input that would copy the table on page 1, paste to excel, then move to page 2 and copy/paste to the next empty row?
View 1 Replies
View Related
Dec 3, 2006
what code can be used to be place in a Command Button on a worksheet that will use the value in a cell, change it to the directory where it have to be saved and save it to the value of another cell. Example:
On a worksheet called "Customer", at cel A1 will be the customer's name and at cell A2 will be the asset number. Now let's say a directory does not yet exist on the root for this customer, a new directory must be created in the root directory by using the name in A1, and the workbook must then be copied and saved under the value of A2.
View 6 Replies
View Related
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
Dec 9, 2009
I've been trying my best to create a directory structure using VBA and Excel, and have run out of patience on how best to do this. My goal is to create a directory tree containing 2 levels. The 1st level (Main Folders) will be named from data in Column A of an Excel Spreadsheet, the 2nd level (Subfolders) will be created from data in Columns B, C and D of the spreadsheet. I've been using the following code with success, but don't know how to create subdirectories:
Sub StartHere()
Dim rCell As Range, rRng As Range
Set rRng = Sheet1.Range("A1:A20")
For Each rCell In rRng.Cells
CreateFolders rCell.Value, "C: est"
Next rCell
End Sub
Sub CreateFolders(sSubFolder As String, ByVal sBaseFolder As String)
Dim sTemp As String
'Make sure the base folder is ready to have a sub folder
'tacked on to the end
If Right(sBaseFolder, 1) <> "" Then
sBaseFolder = sBaseFolder & ""
End If............
View 5 Replies
View Related
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
Nov 20, 2006
I am currentyly using VB to extract some data sets to another tab in the same workbook. I would like to extract the same data to a new workbook that is already created upon running a macro. How do I specify the location of the new workbook and sheets so the code will extract and input correctly?
The code I am currently using is:
Sub RunModel()
Dim Events As Range
'
'
Application. ScreenUpdating = False
Set Events = Worksheets("Inputs").Range("L41:L90")
Worksheets("Results").Range("A5:FX5004").Clear
Worksheets("Results").Range("A5009:FX10010").Clear
y = -100
For x = 1 To 50
View 3 Replies
View Related
Oct 20, 2007
Is it possible to create a VBA script that will list the filenames of files in a set directory? I have about 100 directories, each containing 1000 files and they need to go into an excel spreadsheet (each file on a new row)so they can be audited... ;(
View 3 Replies
View Related
Jun 10, 2008
This should be so easy, but I know I am missing something. I know that you can only create one directory on one statement line at a time with MkDir. in the "var_dir_path" resides a part number that changes dynamically.
Private Sub CreateFolderFromCellPath2_Click()...
View 6 Replies
View Related
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
View Related
Mar 12, 2014
I have a workbook with Macros in it, now I want to create a copy of that workbook using VBA.
Here are the steps i want:
1. Create a copy of an open workbook
2. Open the Copy.
3. Close the original workbook.
View 1 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
May 28, 2008
I have a named range within a sheet. It was pulled across when i performed a move/copy - create copy from another workbook. The name contains characters that cannot be displayed or recognised and so they are displayed as square
symbols. This causes me an issue as i cannot delete the name. Even if i paste the list names, i cannot copy/paste the name as the characters are not recognised. I also tried using a macro to delete all names, which did delete all names, with the exception of this one.
The VB code used was :
Sub Del_Names()
Dim myname As Name
For Each myname In ActiveWorkbook.Names
myname.Delete
Next myname
End Sub
View 9 Replies
View Related
Nov 11, 2003
how can I creat a directory and then save the same file into that directory. At the moment Im using -
ThisFile = Range("T3").Value
ActiveWorkbook.SaveAs FileName:=ThisFile
...which works great, but before I do this, I want to create a folder with the name the name/value in T4, then ofcourse save the file into that folder ....
View 9 Replies
View Related
Aug 25, 2008
How can you add the date from a sheet say A1 which is a long date and make a directory which the date incorporated into the new directory name?
View 2 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
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
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
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
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
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
Nov 5, 2008
I have managed to get my workbook to save with a filename based on two textboxes. I am not sure, however, how to define the directory. I have tried adding a ("mydirectory") on the saveas line but it does not work.
This is my
Private Sub CommandButton2_Click()
Dim wb As Workbook
Set wb = ActiveWorkbook
Dim strText As String
strText = txtLMSRef.Text & "," & txtPartial.Text
wb.SaveAs Filename:=strText
wb.Close
Set wb = Nothing
End
End Sub
View 9 Replies
View Related
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
Mar 6, 2014
Using Dropbox, a lot of people will fill in formulas in personal workbooks from using data from another, central workbook. Since I cannot control where they install Dropbox or where they keep their personal workbooks, I must account for that in functions.
Now, my idea is to make them define the directory of the source in their personal workbook in a specific cell and then using that as a basis for the rest of the functions.
Example
Cell A1: C:Usersuser1Dropboxfolder (copy paste from path in Windows Explorer)
Cell B1: A1&[CentralWorkbook.xlsx]SheetName'!$H$1
Basically I want the unknowing user to copy-paste the path of the central workbook into a specific cell in their own workbook and then build my functions bsed on that. How can this be done?
View 2 Replies
View Related
Jun 18, 2009
I am trying to have the user hit a button and save the workbook in a newly created directory. Currently it creates the new workbook and the new directory with the correct names, however the workbook is not in the newly created directory.
View 5 Replies
View Related
Feb 15, 2010
I want to use the following kill command to delete all files in a folder:
Kill "C:dsmanagerest*.*"
However, I want the directory to be specified not within the code, but within a cell on a worksheet. Ie. Cell A1 would contain the directory C:dsmanager est*.*"
View 6 Replies
View Related