Create Open Copy Of Open Workbook
Jul 30, 2009Create a full copy of an open workbook (eg. activeworkbook MyFile.xls) using VBA, with the new copy (eg Book1.xls) open as well ,without having to save a copy first then open it ?
View 9 RepliesCreate a full copy of an open workbook (eg. activeworkbook MyFile.xls) using VBA, with the new copy (eg Book1.xls) open as well ,without having to save a copy first then open it ?
View 9 RepliesI have created a spreadsheet some time ago and have been asked to improve on it but I'm rusty with VBA.
I have an automated ordering system that saves each sent order as the date e.g "05-04-2013.xls" but the management team want a graph with the data for the last 4 weeks compared. I have created a seperate workbook called "consumables report.xls" which has a column with the products listed followed by columns "Quantity" and "cost" which is repeated for the 4 weeks of the month.
I want to add a button to prompt the user to choose the saved order e.g "05-04-2013.xls" (all orders saved in same directory) to copy and paste the quantity and cost columns (c8,D69) into "consumables report.xls". I got this to work earlier but it would only paste the formulas and not the values. So I need
A prompt to open workbook
Copy range (c8,d69)
Close work sheet
Paste special .value (c8,D69)
I dont care if it has to open the workbook to copy the data as this will only be used once a month so it dosnt matter how slow the code is.
week 1 week 2 week 3 week 4
Product
quantity
cost
quantity
cost
cost
quantity
cost
1
2
3
4
5
6
7
8
I would like to write a Sub that will see if a workbook is open and if it is not then open it. I know how to have a macro automatically open a workbook, but I run into problems when the macro runs and tries to open an already opened workbook.
View 5 Replies View RelatedI am trying to create a simple macro to open a second workbook if the value in a cell in the current workbook is 'x' or if 'y' do nothing.
Basically I have a simple sales ledger, one column has a yes/no for whether or not an invoice is paid if no I want to open a second workbook 'debtors' so that I can manually input the details. I'm sure this is a very simple proceedure but I can't seem to crack it.
My Splash screen opens a few seconds after the workbook has loaded. Is there a way to make the workbook open minimzed until the the splash screen closes then open properly? What I trying to say is that only the splash screen is visible until it closes.
View 5 Replies View RelatedI have Monthly sales sheets that import my cash register data into them. I wanted to set them up to do everything without being there. So I have my task manager open excel at 9:30pm everyday and it runs the macro to import the data into the correct day of the month. Here is the workbook
open macro-
Private Sub Workbook_Open()
Dim dTime As Date
dTime = Time
If dTime >= TimeValue("9:30 PM") And _
dTime < TimeValue("9:40 PM") Then
ImportData
End If
End Sub
This is in my July spreadsheet only. So is there a way to make it know which month spreadsheet to open on the 1st of the month? So come August 1st it will automatically open the August workbook and input the data for the first day? By using the date?
this is a relatively straightforward query, would be obliged for any tips on same. I have the following piece of -
View 2 Replies View RelatedI did a macro on my mac to transfer a sheet from one workbook to another worbook. It works very well when the destination workbook is open. Therefore I wanted to add some piece of code to check if the destination workbook is open. If not then I wanted the macro to open it before tranfering the sheet. Here is the code I´m using for tranfering the sheet
Sub Transfer_Sluttet()
If ActiveSheet.Index <> Sheets.Count Then
Application.DisplayAlerts = False
Set ws = ActiveSheet
Sheets(ws.Index + 1).Delete
ws.Move Before:=Workbooks("Sluttet.xls").Sheets("sheet2")
'Moves active sheet to beginning of named workbook.
'Replace Test.xls with the full name of the target workbook you want.
Application.DisplayAlerts = True
End If
End Sub
This is the type of macro I useually use on my pc to check if a workbook is open and if not then open it
If IsWorkbookOpened("Filename.xls", "C:Documents and ..................
Copy data from workbook, open existing workbook, select range and paste. But my copied data is lost.
Sub Select_Copy_Paste()
'
'
Windows("ElektroFunctiesDatabase.xlsm").Activate
Sheets("PowerSupply's").Select
Range("A2:I6").Select
Selection.Copy
[Code] .........
' Here i need to do something to paste data into r.address?
I run a model in Excel that automatically saves my file every xx iterations. After saving the file I want to make a backup of the file. Tried
[Code] .....
but get a permission denied error message.
I don't want to use .SaveAs as it is a huge file that takes a while to save and SaveAs has a tendency to break links that should not be broken..
Here's my macro:
Code:
Sub CopyRow()'
'Copies row to new sheet, highlights it, marks column 'A' as copied.
'
Dim cCell As Range
Set cCell = Selection.Cells(1, 1)
Selection.Copy
Sheets("Sheet2").Select
Rows("2:2").Select
[Code] .....
Is it possible to modify it to paste into a different workbook called c:filesDestination.xlsm, instead of the existing workbook (Source.xlsm)? The destination sheet name is the same (Sheet2). It's OK if both workbooks are open at the same time.
I am trying to write a piece of vb code that opens a workbook and enters some data into it, saves it as a different file name and closes it.
Basically, I have a worksheet with two sheets. One is a list of a few values (order number, description, date), the other has three cells which the user enters the values into, and a command button. When pressed it transfers the data into the table on the first sheet.
I then need it to open a workbook C:/ewr.xls and put these values into this, rename it as ewr180.xls, (where 180 is the order number) and save it
I'm almost there but just cant seem to get the values into it
I know i must be missing something so simple, any help would be much appreciated.
Private Sub createEWR_Click()
Dim ewnnum As Integer
Dim descr As String
Dim ewndate As String
' enter new row with data
I have a presentation that I open from a short-cut. After the "Welcome Page" is opened, I want to open a second workbook in a new instance of Excel after 4 seconds.
I think that I can open the new instance of excel, but I don't know how to activate the macro after 4 seconds.
I'm sure there is a function someplace for this that can be used in a macro.
Then, after the second Workbook is opened, I want the Welcome Page "Workbook" closed, leaving the second Worbook open.
I know that the line in my code Worksheets.Copy is NOT what I need to have to make this work, but with it it's the closest I could get to what I want.
I want the user to be able to click the SAVE command button, be allowed to either accept or change the default save options, save the current workbook and then go right back to the form that has the SAVE command button. Sounds simple, I know, but when you don't know the right commands to save the WORKBOOK, not just the WORKSHEETS, it becomes a P.I.A.
I know there's a lot there, but here's my code, which is just a slightly altered version of the code by Ron de Bruin:
Private Sub SaveData_Click()
'If no date has been selected then don't allow SAVE
If PubDateLabel.Caption = "" Then
MsgBox "Publication Date not set. You must select a date before saving.", vbCritical, "No Publication Date!"
Exit Sub
End If
I would like to copy all the items below the ITEM row and paste it to cell A2 of another saved workbook (say, Saved.xls).
If Saved.xls is closed, the macro would open it and paste. If it is open then it will just paste.
I'm trying to do something which I believe is simple but my lack of VBA knowledge is getting in the way. How do I open 2 workbooks then copy a sheet from 1 workbook to another?
I can get the workbooks open just can't copy the sheet across? I get a run time error 9, subscript out of range message on copy sheets code
Code:
Private Sub CommandButton1_Click()
'locate file via range and open the document'
[Code]......
how to go about taking data from a closed workbook with a range say A1 to A100, and place it in the work book i have open. I have 3 different sheets in the open work book but all the data is coming from the one sheet in the closed workbook.
View 9 Replies View RelatedI want to open the workbook "Invoice.xls" from the path: D:2008DecemberWorkflow
After opening this workbook, I would like to go to the sheet "Raw Data" and then copy the entire Raw 10. And close the workbook.
I have a VBA-coded macro in an Excel workbook that is to open another existing workbook -- a .xls file, not .csv -- copy data from it, paste that into the original workbook where the macro resides, then close the source workbook.
If I use the debugger to step through the macro -- putting a breakpoint at its first executable line, run the macro, then F8 step through it, it works fine. (With delays at the open, close statements.) Free running, it doesn't. I suspect it's a timing issue, that the macro runs full tilt even though the new workbook isn't yet open -- but I don't know how to remedy that.
Here is the situation and the simplified code (the actual macro does a lot more, of course):
Main workbook: Two sheets, "Parameters" that has the fully-qualified filename for the desired source .xls in A1; and "Data", into which I want to paste data from that source.
Source workbook: Single sheet, "Sheet1"
Macro code. For simplicity, it is trying to copy/paste all of the source worksheet's content:
Sub Go()
'
' Go Macro
' Test of getting data from another spreadsheet
'
' Keyboard Shortcut: Ctrl+Shift+G
'
Dim SourceFile As String
Dim HomeBook As String
Dim OtherBook As String
Sheets("Parameters").Select
SourceFile = Range("A1").Value
HomeBook = ActiveWorkbook.Name
right after the open, hoping that might cause a dwell for the open to complete.
When I step through it, the Locals view has all the parameters, getting set properly. If I try to simply run it, it stalls at the opened source workbook, the Locals view is empty, no data has been transferred into the initiating workbook.
If I place the breakpoint after the open, it is not reached. (I have the VBA open.) Hitting F8 then yields a VB error window, "Compile Error" "Expected: To"
I'm trying to write a macro that accomplishes the following:
" Book 1" is already open. The user runs a macro that lists all .xls files in directory "d:measurements" The user selects the desired file from the list or box the macro copies from this "book 2" " sheet 3", " range A6:I107 and pastes (values only) into "book 1", "sheet 5", "range A6" End of macro.
I want to accomplish this without opening the selected file (book 2)
is it possible to write vb code to open the workbook, scroll through everysheet? extract the values from each worksheet?
let's just say, I only know the workbook name, but not the sheets of the name inside. So the vb code could scroll through every worksheet without knowing the worksheet name, only the workbook name(workbook.xls)
This is pretty basic I just don't know what command to use. I have a macro that's supposed to copy data from one workbook to another, it works fine but In the macro it open the other workbook then closes it. I would like the macro to not reopen the second workbook if it is already open (since reopening causes it to lose the newly updated info). I think it can be done with a If command but I don't know which tried the following: If workbooks("M:/database") Is Open but of course 'is open' doesn't work, but can anyone tell me what to use instead.
View 2 Replies View RelatedNeed some VB Code to check if a workbook is open or not. Either way, it needs to be opened and made active.
I have tried using some of the answers already on here but not getting anywhere.
Looking for a macro, to run upon opening file, that opens a linked file and if the file is already open does nothing.
View 2 Replies View RelatedI have 3 workbooks open. 1 is my working file and I name it as "Final[date].xlsm". The other 2 files are my source files which are also open are named as source1.xlsx and source2.xlsx. Both the source files has only one tab/sheet as "Sheet1". My objective is to bring the contents of the source file to my working file in 2 different sheets. all the contents in Sheet1 of "Source1.xlsx" should be paste.values only to the "Final[date].xlsm" with a sheet name "BankDetails". This will enable the user also to replace the old data in "BankDetails" tab. The "source2.xlsx" sheet1 has a different situation. I need to copy only the cells with values, not the entire cells, because it has to be pasted (values only) to range C2:L. I have formulas in the other columns before C and after L.
Take note that my working file name is changing every based on the date while my source file has always same file name.
Code, couldn't make it work with VB HTML Maker. I'm new with VBA Basically my idea is when someone open default file, insert data, try to save file, macros save workbook with inserted data as another file (*.xlsx) and make pdf in another folder. Pdf part is working fine, but with second part just can't find right option.
Pdf part
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
Dim Name As String
Dim i As Integer, j As Integer
Name = ThisWorkbook.Path & "PDF Archive" & ActiveSheet.Range("F6") & " Invoice " & ActiveSheet.Range("B11")
[Code]...
Excel part
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim ActSheet As Worksheet
Dim ActBook As Workbook
Dim CurrentFile As String
Dim NewFileType As String
Dim NewFile As String
[Code]...
I've got a kind of "menu" sheet that will pull up various reports from Excel spreadsheets. Rather than having the user work with the live data, the menu opens the file and saves it as a copy, closing the original. This is working fine.
The tweak I want to add is, since the user is looking at a copy rather than the live data, I don't want them to save when closing. Is it possible to programatically add a bit of code to the new copy to handle this?
Here's a sample of one of the menu button's code:
Code:
Private Sub CommandButton18_Click()
Dim wb As Workbook
Set wb = Workbooks.Open(Filename:="J:Z PII OvensRack Repair TrackingRack Repair List.xlsx")
With wb.Worksheets("Sheet1")
.Unprotect Password:="pass"
ActiveWorkbook.Worksheets("Sheet1").Copy
End With
[Code].....
Is it possible, in vba, to copy two sets of cell values to two clipboards (clipboard1 and clipboard2?), open another workbook and paste those two seperate clipboard values into another two cells?
View 3 Replies View RelatedI want to create a standard macro that will copy values from a Master workbook to the current, active workbook I have open. The problem I have run into is when I record a macro it also records the name of the active workbook I'm copying data into and I would like it so when I bring up a workbook I just run the macro and it copies the values in. I'll be doing 8 different macros that each copy different values from the Master spreadsheet
View 8 Replies View RelatedI'd like to know if it is possible to run a macro in a workbook that will open another workbook (of the users choice) extract data from it, such as columns from its sheets then paste that data into the workbook the macro is running from. The file to be opened will change, so i've found some code that enables the user to select the file to open then open it.
Dim strFile As String
strFile = Application. GetOpenFilename
If strFile <> "False" Then Workbooks.Open strFile
This brings up the standard windows choose file to open box, then opens the selected file. Am I correct in thinking that the Dim here will store the file name I select in the open file box? If so, I'd like to know how to select the workbook using the dim so I can manipulate it from the workbook I'm running the macro in. Incidentally, once the the data has been copied, I'd like the workbook opened with the macro to be closed.