+ Reply to Thread
Results 1 to 9 of 9

runtime error 424 Object Required

Hybrid View

pongmeister runtime error 424 Object... 02-28-2018, 11:04 AM
CK76 Re: runtime error 424 Object... 02-28-2018, 11:15 AM
pongmeister Re: runtime error 424 Object... 02-28-2018, 03:25 PM
CK76 Re: runtime error 424 Object... 02-28-2018, 03:42 PM
pongmeister Re: runtime error 424 Object... 02-28-2018, 04:05 PM
pongmeister Re: runtime error 424 Object... 03-01-2018, 12:31 PM
CK76 Re: runtime error 424 Object... 03-01-2018, 12:34 PM
pongmeister Re: runtime error 424 Object... 03-02-2018, 12:36 AM
pongmeister Re: runtime error 424 Object... 03-01-2018, 05:01 PM
  1. #1
    Forum Contributor
    Join Date
    07-20-2015
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2016
    Posts
    314

    runtime error 424 Object Required

    I get the runtime error 424 Object Required message when I run the vba code below. To insert this code I right clicked the worksheet "Results" in workbook "DoubleElimResults.xlsm". I'm trying to activate the workbook "DoubleElimDrawSheet.xlsm" but get the error when the line - "Workbooks(“DoubleElimDrawSheet.xlsm”).Activate" is reached. I can put the activate command in a regular macro and it works fine but I need to have it in this code so I can change background colors on the draw sheet when a cell in the target range changes. This is just the initial vba code to get it working and I will have well over 150 cells to manipulate which is cumbersome to set up using conditional formatting.

    Here is the code and I'm attaching the two workbooks plus a third which isn't part of the problem but is referenced in formulas.

     Private Sub Worksheet_Change(ByVal Target As Range)
        Dim KeyCells As Range
    
        ' The variable KeyCells contains the cells that will
        ' cause an alert when they are changed.
        Set KeyCells = Range("B18:B34")
        Dim MatchID As String
        Dim MatchPos As String
        
    
        
        
        If Not Application.Intersect(KeyCells, Range(Target.Address)) _
               Is Nothing Then
            If Target.Address = "$B$18" Then
               If Range("C18").Value = "U" _
               Or Range("C18").Value = "L" Then
                  MatchID = "W17"
                  MatchPos = Range("C2").Value
                  Workbooks(“DoubleElimDrawSheet.xlsm”).Activate
                  Sheets(“Brackets”).Select
                  If MatchPos = "U" And Range("J1") = "Y" Then
                     Range("P70").Interior.Color = RGB(255, 255, 0)
                     Range("I70").Interior.Color = RGB(146, 208, 80)
                  Else
                     Range("I70").Interior.Color = RGB(102, 255, 51)
                     Range("I70").Interior.Color = RGB(146, 208, 80)
                  End If
               End If
            End If
    
    
             Windows("DoubleElimResults.xlsm").Activate
        End If
    End Sub
    Thanks for any help resolving this error.
    Attached Files Attached Files

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: runtime error 424 Object Required

    Is the workbook "“DoubleElimDrawSheet.xlsm” open already when the code runs?

    If not, you need to first open the workbook before you can activate it.

    But you really don't need to activate or select object in code.

    Instead use something like below.
    Dim wb As Workbook
                  Set wb = Workbooks.Open("DoubleElimDrawSheet.xlsm")
                  With wb.Sheets("Brackets")
                    If MatchPos = "U" And .Range("J1") = "Y" Then
                       .Range("P70").Interior.Color = RGB(255, 255, 0)
                       .Range("I70").Interior.Color = RGB(146, 208, 80)
                    Else
                       .Range("I70").Interior.Color = RGB(102, 255, 51)
                       .Range("I70").Interior.Color = RGB(146, 208, 80)
                    End If
                  End With
    This assumes both workbooks are in same folder.
    "Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something."
    ― Robert A. Heinlein

  3. #3
    Forum Contributor
    Join Date
    07-20-2015
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: runtime error 424 Object Required

    CK76,

    Both workbooks are in the same directory. I tried your suggestion but I get an error message: "Sorry, We couldn't find "DoubleElimDrawSheet.xlsm". Is it possible it was moved, renamed or deleted?"

    Both workbooks are open before the code is invoked. Also, I put the set wb code in a named macro and the same thing occurred. I also looked at the directory and copied the workbook name from the
    directory list and then did a find in the macro and it matched perfectly. The temp macro code is named "TEMP3" in "DoubleElimResults.xlsm", which was attached in my orig. post.

    Thanks much for your help

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: runtime error 424 Object Required

    Hmm, your code runs fine on my system.

    Or with following modification.
            If Target.Address = "$B$18" Then
               If Range("C18").Value = "U" _
               Or Range("C18").Value = "L" Then
                  MatchID = "W17"
                  MatchPos = Range("C2").Value
                  With Workbooks("DoubleElimDrawSheet.xlsm").Sheets("Brackets")
                  If MatchPos = "U" And .Range("J1") = "Y" Then
                     .Range("P1").Interior.Color = RGB(255, 255, 0)
                     .Range("I2").Interior.Color = RGB(146, 208, 80)
                  Else
                     .Range("I2").Interior.Color = RGB(102, 255, 51)
                     .Range("P2").Interior.Color = RGB(146, 208, 80)
                  End If
                  End With
               End If
            End If

  5. #5
    Forum Contributor
    Join Date
    07-20-2015
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: runtime error 424 Object Required

    I have to leave my workplace and will be gone for several hours. I will try your code tomorrow morning.

  6. #6
    Forum Contributor
    Join Date
    07-20-2015
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: runtime error 424 Object Required

    CK76,

    Thanks so much for the solution. I used your code above and it works perfectly!!

  7. #7
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: runtime error 424 Object Required

    You are welcome and thanks for the rep

  8. #8
    Forum Contributor
    Join Date
    07-20-2015
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: runtime error 424 Object Required

    Hi CK76,

    I just want to let you know the current situation. I replied to you that I was re-opening this thread, due to runtime error 424 which you can see in my reply to you below. No need to look for a solution as I have found a way around it.

    Basically I run a macro from the vba code in the Results worksheet - the macro being submitted is in the DoubleElimDrawSheet.xlsm workbook and I can update with less complexity.

    Thank you again for your help.

  9. #9
    Forum Contributor
    Join Date
    07-20-2015
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: runtime error 424 Object Required

    Hi CK76,

    I re-opened this thread because I'm finding the coding complexity is increasing as I code the advancing brackets in the tournament. I've tried to reference cells from the "DrawSheet" which would really uncomplicated the process of finding who advanced and their corresponding cell color.

    Example: when I put in a reference to a cell to check it's value For Instance "N4" and single step thru the code then hover over the code
     TesterField = Range("N4").Value
    It shows me the value in the results workbook at N4. I plugged a value in
    the results N4 field to validate.

    I set up a string field named TesterField to check it out.

    I've tried putting the commands: Workbooks("DoubleElimDrawSheets.xslm").Activate and Worksheets("Brackets")
    and tried it using the With Workbooks command but couldn't get valid results.

    Any ideas how I could accomplish this?

    Thanks again
    Last edited by pongmeister; 03-02-2018 at 12:31 AM. Reason: More info now available

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Trying to put everything together - runtime error 424 object required
    By jimmisavage in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-18-2018, 08:57 PM
  2. VBA with IE: Runtime Error 424 - Object Required
    By FallingDown in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 02-05-2016, 03:47 PM
  3. Runtime Error 424 - Object Required
    By CBalazic in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-16-2015, 01:02 PM
  4. Runtime Error - Object Required
    By darkblueblood in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-11-2014, 07:21 AM
  5. Runtime error 424 Object required
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-10-2013, 09:37 AM
  6. Runtime error 424 Object Required - HELP ME
    By joh46k in forum Excel General
    Replies: 1
    Last Post: 05-09-2013, 01:09 AM
  7. Runtime Error 424 - Object Required
    By teaker in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-09-2009, 04:04 PM

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