Results 1 to 9 of 9

Copy sheet to closed workbook

Threaded View

  1. #1
    Registered User
    Join Date
    11-29-2016
    Location
    Australia
    MS-Off Ver
    10
    Posts
    4

    Copy sheet to closed workbook

    Well I need a little help being a VBA novice.
    I am attempting to save a sheet named Summary from a workbook named RPSDATAFILE.xlsm to a closed workbook named TestDataSheetASX1.xlsx before sheet 1.
    I have used this vba code in Module 4 which appears to work –

    Sub sb_Copy_Save_Worksheet_As_Workbook()
     'Copies summary worksheet data upgrade to new workbook before sheet 1'
     Dim wb As Workbook
     Set wb = Workbooks.Add
     ThisWorkbook.Sheets("Summary").Copy Before:=wb.Sheets(1)
     Application.DisplayAlerts = False
     wb.SaveAs "C:\Users\Mike\Desktop\TestDataSheetASX1"
     wb.Close
     ThisWorkbook.Activate
     End Sub
    The issue I have is that I am running a code in the open workbook RPSDATAFILE.xlsm that runs an application on time for other modules as below

    Private Sub Workbook_Open()
     Application.OnTime TimeValue("09:45:00"), "GetData"
     Application.OnTime TimeValue("09:50:00"), "TestBeep()"
     Application.OnTime TimeValue("11:59:00"), "GetData"
     Application.OnTime TimeValue("12:05:00"), "TestBeep()"
     Application.OnTime TimeValue("12:15:00"), "sb_Copy_Save_Worksheet_As_Workbook()"
     Application.OnTime TimeValue("12:20:00"), "TestBeep1()"
     Application.OnTime TimeValue("15:30:00"), "GetData"
     Application.OnTime TimeValue("15:32:00"), "TestBeep()"
     Application.OnTime TimeValue("15:40:00"), "sb_Copy_Save_Worksheet_As_Workbook()"
     Application.OnTime TimeValue("15:42:00"), "TestBeep1()"
     Application.OnTime TimeValue("17:00:00"), "GetData"
     Application.OnTime TimeValue("17:05:00"), "TestBeep()"
     End Sub
    When the open workbook code runs it performs the first 4 application on times however when it runs the module to copy the sheet I get the following error message.

    Cannot run the macro ‘sb_Copy_Save_Worksheet_As_Workbook() The macro may not be available in this workbook or all macros may be disabled.
    I think that the macro loses focus to the open workbook code when it runs the copy.
    Any suggestions would be appreciated.
    Last edited by MikeBike; 10-30-2017 at 11:37 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] vba code to copy a specific sheet from a closed workbook to the active workbook
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-01-2017, 03:09 AM
  2. [SOLVED] macro to copy specifc sheet in closed workbook to the active sheet
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-07-2017, 09:53 AM
  3. [SOLVED] vba copy specific sheet from closed workbook to active workbook
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-12-2017, 01:33 PM
  4. [SOLVED] copy specific sheet from closed workbook to active workbook
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-10-2017, 10:26 PM
  5. vba copy specific sheet from closed workbook to active workbook
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-09-2017, 02:34 PM
  6. VBA to copy a sheet from a workbook into another workbook that is closed
    By K_Rene in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-20-2016, 10:35 PM
  7. Copy One Sheet From One Closed Workbook To Another Closed WB
    By teshiburu1988 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-04-2009, 11:49 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1