Results 1 to 8 of 8

Runtime Error 424 generated when activating file identified in cell

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365 Version 2501 64-bit
    Posts
    1,465

    Runtime Error 424 generated when activating file identified in cell

    Attached ORDER file has DropLists of Products and Suppliers in Cols B - C

    Attached Supplier file contain PRODUCT and COST columns.(Real folder has several different supplier files).

    User selects a Product and then a Supplier.

    Worksheet change finds the relevant Supplier file, the Product selected in the ORDER file, and copies the Cost from Col B of the SUPPLIER into Col D of the ORDER file.

    
    Option Explicit
    Dim a As Long
    Dim KeyCells As Range
    Dim wkb As Workbook
    Dim wks As Worksheet
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    'Find last row with data in Col C
        
        With ActiveSheet
        a = .Cells(.Rows.Count, "C").End(xlUp).Row
    
    'Set Cells that will cause an alert when they are changed.
        Set KeyCells = .Range("C2:C" & a)
        
    'Exit Macro if more than one cell is chosen
        If Target.Count > 1 Then Exit Sub
        
    'Run Macro if one cell in Col C changes
        If Not Application.Intersect(KeyCells, .Range(Target.Address)) Is Nothing Then
    
    'Set workbook "selected" in the target cell, and add ".xls" as extension ***throws a "RuntIme Error 424 - Object Required"***
        Set wkb = Sheet1.Range(Target.Address) & ".xls"
            
    'Set sheet 1 of that workbook as the sheet to check
        Set wks = wkb.Sheet1
        
    'Find the relevant file for whichever Supplier is selected in the Target cell, find the Product in the Supplier Col A matching Col B on the Target row, copy the value from Supplier Col B into Col D of the Target row in the ORDERS file
        .Range(Target.Address).Offset(0, 1) = Application.WorksheetFunction.Index(wks.Range("B:B"), Application.WorksheetFunction.Match(.Range(Target.Address).Offset(0, -1), wks.Range("A:A"), 0))
        
        End If
        
        End With
        
    End Sub
    All solutions, suggestions and alternatives welcome as ever.

    Ochimus
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Need Help with Runtime Error if same file exists
    By whrsma in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-07-2017, 12:48 PM
  2. Runtime error '53': File not found
    By blindbeggar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-12-2016, 04:09 AM
  3. Error 1004 when trying to save file with name generated from cell value
    By Terios1951 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-15-2015, 04:49 PM
  4. [SOLVED] Runtime error '53': File not found
    By abousetta in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-03-2015, 02:36 PM
  5. runtime error 52 bad file name or number
    By fabdullaster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2013, 06:55 AM
  6. File Name Causes Runtime Error 1004
    By Robert in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-10-2005, 10:55 AM
  7. Activating cell in a file
    By Roger in forum Excel General
    Replies: 2
    Last Post: 07-07-2005, 07:05 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