Close The Source Workbook After Copying

Jan 15, 2009

I manage to copy a worksheet into a new workbook, but how can I change to the old one and close it without saving

View 9 Replies


ADVERTISEMENT

Compile Error On Close Of Excel 2003 But Not On Close Of Workbook

Mar 22, 2012

I am using Excel 2003.

It’s been working perfectly up until around an hour ago. However, now when I close Excel, I get compile errors.

These compile errors seem to be because Excel is trying to access controls in the workbook after it has closed. Since the workbook is closed, VBA can no longer ‘see’ the controls, and therefore it thows up errors.

I’m also getting a similar error on a Worksheets("DataExplorer").unprotect line, which seems to be because the worksheet isn’t there after closing.

These errors only occur when I close the whole excel application using the big cross in the top right. If I just close the workbook (using the smaller cross just below the big cross in the top right of excel), it doesn’t throw up these errors.

Just to clarify: all of the code runs perfectly when Excel is open. The errors are being thrown up for lines of code which run without problem until Excel is closed.

View 9 Replies View Related

Using VBA To Open And Close Source File

Feb 1, 2010

I am working with a bunch of files to do a dashboard. I have the main file which shows end results and what my users will see "Dashboard". I have about 10-15 files which I export weekly from MS Access. and I have the "Dashboard Data" file. In this file I have a sheet which links all the information for the files exported from MS Access. In here I have named ranges and dynamic ranges plus additional columns created to look up information in other tables. I use this file as my source data for my Dashboard File so that I can reduce the size of the actually dashboard. Dashboard Data file is about 5.5 mb and my Dashboard is 300kb. I have 12 branches that need to view the data over a radius of a hundred miles so the smal file are better.

My problem: I can get the Dashboard Data file to update without opening all the 10-15 other files. I cant however make the Dashboard file update without opening the Dashboard Data file. I have it to auto update without prompting but its still tells me that it cannot update. I was wondering if there is some VBA code I could use that would work like this:

I open the Dashboard File, Dashboard Data file opens so that Dashboard file updates and then close Dashboard Data File so that the user never has to see the Dashboard Data file. I dont want them to see it or have access to it.

View 11 Replies View Related

Moving Data From Source To Destination With Open / Close

May 12, 2014

My first shot at a function! hows it look?

Code:

Function wbIsopen(wbname As String) As Boolean
On Error Resume Next
WbIsOpen - (workbooks(wbname).Name = wbname)
End Function

[Code]...

This is also my first shot at using a DIM and Set. I am attempting to move the data from 1 workbook sheet to another after it has been sorted. But if i only have the source open i want it to open the destination workbook and sheet then paste and close the source sheet. If the source is open I want it to go to the next command.

View 3 Replies View Related

Copying Formula Down With Horizontal Source Data

May 26, 2013

I am trying to copy a formula in B38, down to B36

My formula needs to refer to data in of cells in a horizontal succession, G1, H1,, I1...etc

Copying my formula down from B38 causes the formula to refer to G1, then G2, G3... instead of G1, H1, I1 ...

The exact formula in B38 is: =$B$3*(G3*(1-$D$13))

Where G3 should advance to H3, when I drag to copy the formula from B38 to B39. Instead, G3 advances to G4.

View 2 Replies View Related

Refresh All Queries On Workbook Open When Finished Print To PDF Then Close Workbook

Jan 23, 2014

I have data that daily needs to be refreshed and printed to pdf.

I figure the simplest way to do this would be to task schedule the workbook to open daily. Then on open it will refresh the data, print it after all data has been refreshed and close the workbook.

I set it up originally without the need to print so I have all the queries set to refresh when opening the file, however when I now try and put the code to print to pdf on the workbook open event it runs before the queries are finished running. (Query notes: queries were created through Microsoft query, and are accessing a MySQL database queries set to refresh when opening the file queries set to enable background refresh).

View 4 Replies View Related

Copy Values From A Worksheet To Another Workbook. Source Workbook Name Unknown

Aug 12, 2009

I need to copy a range of values (actually two ranges). The ranges are of fixed size. Le't say A2:D20 and E2:H20.

Both workbooks have the exact same layout, and they both have the same named worksheet (in this case it's called Entry). However the actual filename of the source workbook is unknown. I know numerous users have changed the filename of the xls file.

I want to instruct them to open the old and new workbook, and open a third workbook containing the copy macro, they run the macro and it copies the data.

How can I reference a known worksheet name but of an unknown workbook name esp when the source and destination share the worksheet name?

View 3 Replies View Related

Formula In Destination Workbook Will Not Update When Change Tab Name In Source Workbook

Jul 17, 2014

I am working with multiple workbooks with several tabs in each one. I need the forumula to update the "sheet name" from the source workbook even if the destination workbook is closed.

this is a portion of the forumula I am working with:

=SUM(IF(AND([L2_EI_Phase_II_monitoring_workbook.xlsx]Sheet25!$I$4>=182,[L2_EI_Phase_II_monitoring_workbook.xlsx]Sheet25!$I$4=182,
[L2_EI_Phase_II_monitoring_workbook.xlsx]Sheet26!$I$4=182,
[L2_EI_Phase_II_monitoring_workbook.xlsx]Sheet27!$I$4

View 9 Replies View Related

Close And Reopen Workbook From Macro Stored Inside Workbook

Mar 30, 2007

I have a Macro that is stored in a specific workbook,"Projection Modeler.xls" the last line performed in this macro is the close workbooks without saving chages(this needs to be done due to the way this macro was written, and it would take too long to rewrite). If I would then like to reopen this workbook, and then rerun this macro, can I do this from inside the current macro (in a new sub routine, for instance), or do I have to write a macro outside of the workbook and then open the workbook and call the routine?

View 4 Replies View Related

Excel 2007 :: Date Format While Copying Data From Another Source?

Jul 14, 2013

I have some data coming in from another source system which has the date format as "DD-MM-YYYY" but while pasting it to Excel (2007) sheet some date fields has just DD-MM-YY format which disrupts my macro. I did changing the language settings to "English(UK)" ,which i wanted, and changed the same in Excel options as well. But unfortunately it doesn't work.

View 3 Replies View Related

Reference A Source Workbook By Having The Title In Destination Workbook?

Jun 6, 2014

I want see if it's possible to take the name of the source workbook and put it in a cell in my destination workbook and then use that as the reference in formulas. The source document title includes a date that changes yearly, or in some instances changes entirely, and I want to keep the formulas in the destination workbook intact. I don't want to have to go to every instance where I have used the source workbook and change the title. Instead I would like to copy the source workbook title, paste it into the destination in the same cell and have that propogate the needed changes into the destination workbook formulas.

View 2 Replies View Related

Excel 2010 :: Close Second Workbook From Workbook BeforeClose?

May 27, 2014

I cannot make this work in XL2010.

I am opening a second workbook in ReadOnly in the Workbook Open and Closing it in the Workbook BeforeClose.

I don't EVER want to save changes on either workbook.

I need to leave excel open as the macro created a 3rd workbook which the user will need.

[Code]....

View 6 Replies View Related

Copy Range To New Workbook & Close Existing Workbook

Jun 30, 2008

I have a very brief question

dlgAnswer = Application.Dialogs(xlDialogOpen).Show
Selection.Copy
Windows("Derivative YK pricing Mod G.xls").Activate
Columns("B:B").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Range("C5").Select
Application.CutCopyMode = False
Windows("EXPORT1.xls").Activate
ActiveWindow.Close

As you can see, I open a workbook with the dlgAnswer, I was wondering how I could close that opened workbook

Currently I have

Windows("EXPORT1.xls").Activate
ActiveWindow.Close

however the workbook will not always be called export1.xls, I want it to close whichever one I opened earlier.

View 9 Replies View Related

Save Workbook On Workbook Close

Aug 26, 2006

I snagged this code out from another project I wrote, and it works fine in that one, but doesn't in the new project.

What I want, is when the person presses the exit button, it will save whatever was done, its running as a form printer and database. The code below is the code for my exit button.

Private Sub CommandButton4_Click()
Dim sAnswer As String
Dim i As Integer

' ****************
' ** Exit Button**
' ****************

When it gets to "If ActiveWorkbook.Saved = False Then" it does put the question out "Do you want to save changes" I click Yes and it doesn't save it.. I have tried both activeworkbook and thisworkbook ... I copied the code and verified all is good to go..

View 9 Replies View Related

Creating New Workbook / Copying Sheets And Saving Workbook - Subscript Error

May 30, 2014

Trying to create a new workbook from another open workbook, then copying all the sheets that aren't called "Summary" to that new open workbook and then saving it. I get a subscript error on this line:

[Code]....

View 3 Replies View Related

Copying Data From Recently Opened Workbook To Workbook Where Form Is Present

Jun 16, 2014

All i did was i just created a form to open a workbook from the directories.

Code to copy the data from that recently opened workbook to my workbook where I have my forms. I need to copy that data as in the case that i don't know the workbook and the sheet name i'am going to open as i may open any of the files!!

View 2 Replies View Related

Save And Close Workbook Using VBA

Dec 11, 2013

How can i save and close one workbook in excel with vba code.

View 2 Replies View Related

Make One Workbook Close Another

Apr 9, 2007

How can I make one workbook close another without saving?
These all work in the immediate window, but not in the
Private Sub Workbook_BeforeClose

View 9 Replies View Related

Close A New Workbook After Email

May 7, 2009

I have the below code in a macro attached to a button. Basically, if i choose yes to the message box at the beginning then the macro copies the all the cells on the sheet 'selections', opens up a new workbook, pastes into here, deletes some unused cells, rows and columns, then sends the sheet as an attachment on an e-mail.

What i also need to do is when i have sent the e-mail, the macro closes the new workbook without saving changes.

View 13 Replies View Related

Code For Close The Workbook

Jul 11, 2009

I know this is the code to close a workbook

View 5 Replies View Related

Close Workbook With Macro

Sep 22, 2009

I have a workbook that contains 4 macros. This workbook is copied by vb.net application with another name. When I run the macro in the copied worksheet, the Original file/workbook is opened automatically, and it is open until the copied workbook is closed.

My question:

1) Is this normal, when a copied workbook invokes a macro from the original workbook, the original workbook opens?

2) Is it possible to close the original workbook while executing the macro from the copied workbook?

3) Will that affect the macro in the copied workbook?

4) If possible to close the original workbook, kindly help me with the code.

View 14 Replies View Related

VBA - Close Workbook After 15 Minutes

Apr 2, 2013

I somehow need to add to the section of code below a event to have the "(Public)Archive.xls" to automatically close 15 minutes without saving everytime it is opened.

Code:
Kill "H:AllMaterial Prep Archive(Public)Archive.xls"
Columns("A:H").Select
Selection.Copy

[Code].....

View 1 Replies View Related

Workbook Before Close Event

Jul 22, 2008

I have a sheet that on open looks at the username and determines which tabs can be seen by that user. If macro's are not enabled, I want the sheet to just display sheet 4.

here is the code I have on open that works fine: -

Private Sub Workbook_Open()
If Environ("username") = "Bob" Then
Sheets("Sheet1").Visible = True
Sheets("Sheet2").Visible = False
Sheets("Sheet3").Visible = False
Sheets("Sheet4").Visible = False
Else
Sheets("Sheet1").Visible = False
Sheets("Sheet2").Visible = False
Sheets("Sheet3").Visible = False
Sheets("Sheet4").Visible = True
End If
End Sub

I have a Workbook_BeforeClose() function that does not, and I am stuck as to why!

Here it is: -

Private Sub Workbook_BeforeClose()
If Environ("username") = "Bob" Then
Sheets("Sheet1").Visible = False
Sheets("Sheet2").Visible = False
Sheets("Sheet3").Visible = False
Sheets("Sheet4").Visible = True
ThisWorkbook.Save
Else
Sheets("Sheet1").Visible = False
Sheets("Sheet2").Visible = False
Sheets("Sheet3").Visible = False
Sheets("Sheet4").Visible = True
End If
End Sub

So basically after "Bob" is done it will save the sheet with only tab 4 visable. This means that if someone without Macros enabled opens the sheet they can only view tab 4 (I know it isn't password protected in this example, but it will be)

View 9 Replies View Related

Auto Close A Workbook

Jan 18, 2009

Is there anyway that a workbook can be set up to close itself at a set time i.e 19.00hrs every day?

View 9 Replies View Related

Workbook Close Message Box

May 11, 2009

is it possible to have a messagebox activate when closing a workbook.

View 9 Replies View Related

Save Workbook & Close

Jul 8, 2006

One of my computers pulls info from my cash register once everyday (sales info). Then I have a excel monthly sales sheet that pulls the info from the register info and puts it in the right places. So the computer pulls the register info at 9:20pm everyday, then I have my task manager open excel at 9:25 everyday and it has a workbook open macro to automatically pull the info into the excel spreadsheet. Here's my problem-- I need to close it.

I'm sure I could use a workbook close macro, but when it tries to close it won't it come up with a save, don't save, cancel prompt? Nobody will be there to hit SAVE so it won't close? Is there just a macro that could save it then close it?

View 9 Replies View Related

Workbook Still Shows In VBE After Close

Feb 15, 2008

I have an Excel workbook that runs some code in the back. When I close the workbook file it seems to close OK. However if I then open the VBA editor window I still see the file in the project explorer. If I re-open and then close I have 2 instances in the project explorer... and so on. I have tried setting all objects to nothing etc. but the problem still manifests itself.

View 4 Replies View Related

Excel 2007 :: Copying Data And Graphs De-linking Source Data?

Dec 27, 2012

I have a simple reporting sheet where the data for orders place is in one sheet and on the other sheet is an imput box for 'date' and it filters through and presents a table of data and two graphs for the date chosen.

I give a daily report (contents of this sheet) but I also need to leave this sheet available for anyone to open and change to another date.

I want to copy the repor sheet into a new one and email but I want the graphs to remain, not go blank when anyone changes the original sheet.

Excel 2007 / Windows 7.

View 3 Replies View Related

Copying Data From Userform To Another Workbook Without Opening Second Workbook

May 16, 2014

I have created userform and it works fine. Following code assigned to 'SUBMIT' button in userform - works fine. I am trying to include code where certain data from userform is also copied to workbook2 ( of course without opening it)- as marked in red...below

[Code].....

View 4 Replies View Related

Copying EMF Object From Closed Workbook Into Open Workbook

May 27, 2014

Please see attached files.
Book1.xlsx
test.xlsm

I am trying to copy the emf image object from "Book1" into the "test" workbook whilst the test workbook is open and Book1 is closed. The code I have put together currently sort of works, I mean that it copies the text data over but does not copy the object which is what I require.

View 2 Replies View Related







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