Results 1 to 3 of 3

Excel 2010-2016 upgrade and code not working unless cell in active workbook is highlighted

Threaded View

  1. #1
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Excel 2010-2016 upgrade and code not working unless cell in active workbook is highlighted

    I just upgraded from excel 2010 to 2016 and now I am getting a debug error when I start the macro at the line 'Workbooks("Live Trade Monitor - IB.xlsm").Worksheets("Live Trades").Select' only if my cursor is selecting a cell in a separate excel workbook that I have open. If my cursor is selecting a cell in the active workbook in which this macro runs then the code runs correctly. If someone can help me correct this error I would appreciate it. Thanks


    The error that I am receiving is
    Run time error '1004'
    Select method of worksheet class failed




     
    
    Option Explicit
    Dim iCount As Integer, iNumber As Integer, rStart As Range
    
    Sub CopyLiveTradeData()
    
    
            Dim UserInput As Integer
        UserInput = MsgBox(Title:="Confirm Continue", _
                           Prompt:="Are you sure you want to start the PnL recorder?", _
                           Buttons:=vbYesNo)
        If UserInput = vbNo Then Exit Sub
        
        'If user clicked yes, any code below this point will run
        'For example:
        
    
        Application.OnTime TimeValue(ThisWorkbook.Sheets("Live Trades").Range("X57").Value), "StartOnTime"
            
    
    
    End Sub
    
    Private Sub StartOnTime()
    
    
        iCount = 0
        iNumber = 20000
        Workbooks("Live Trade Monitor - IB.xlsm").Worksheets("Live Trades").Select
        
        
        Call OnTimeMacro
        
    
    
    End Sub
    
    Private Sub OnTimeMacro()
    
    
    
        If Time < TimeSerial(15, 59, 0) Then
            iCount = iCount + 1
            Application.OnTime Now + TimeValue("00:00:30"), "RunEveryXMinute"
        Else
            Workbooks("Live Trade Monitor - IB.xlsm").Worksheets("Live Trades").Select
        End If
        
    
        
    End Sub
    Last edited by rhudgins; 05-17-2016 at 12:41 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Print current page with active cell with VBA code Excel 2010
    By ruznemat in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2017, 08:42 AM
  2. Excel 2016 upgrade added password
    By laguna92651 in forum Excel General
    Replies: 0
    Last Post: 12-22-2015, 07:01 PM
  3. How to upgrade VBA code for Excel 97-2003 to Excel 2008 or 2010
    By Balachan56 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-20-2013, 05:07 AM
  4. [SOLVED] [EXCEL] Open and copy from workbook specified in existing cells / 2010 upgrade problem
    By morten.bay in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-27-2012, 04:20 AM
  5. [EXCEL] Open and copy from workbook specified in existing cells / 2010 upgrade problem
    By morten.bay in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-22-2012, 09:07 AM
  6. Excel 2010 upgrade from 2003
    By cmar6 in forum Excel General
    Replies: 2
    Last Post: 08-06-2012, 12:37 PM
  7. code doesnt work after upgrade to 2010
    By jmckee in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-12-2011, 09:57 AM

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