+ Reply to Thread
Results 1 to 2 of 2

Excel Runtime Error 429 in VBA on MAC

Hybrid View

  1. #1
    Registered User
    Join Date
    12-13-2023
    Location
    Fairbanks, AK
    MS-Off Ver
    16.78.3
    Posts
    1

    Excel Runtime Error 429 in VBA on MAC

    I am getting the Runtime error 429 in Excel VBA for my macro. It works fine on a Windows PC. I think it has to do with me using
    Set dict = CreateObject("Scripting.Dictionary")
    . I am no familiar with writing VBA code for Macbooks. I would like to have help if anyone would not mind in fixing this code to work in Excel on a Mac.
    Sub CleanDupes()
        Dim targetArray, searchArray
        Dim targetRange As Range
        Dim x As Long
    
        'Update these 4 lines if your target and search ranges change
        Dim TargetSheetName As String: TargetSheetName = "New list"
        Dim TargetSheetColumn As String: TargetSheetColumn = "A"
        Dim SearchSheetName As String: SearchSheetName = "Unsubscribes"
        Dim SearchSheetColumn As String: SearchSheetColumn = "A"
    
        'Load target array
        With Sheets(TargetSheetName)
            Set targetRange = .Range(.Range(TargetSheetColumn & "1"), _
                    .Range(TargetSheetColumn & Rows.Count).End(xlUp))
            targetArray = targetRange
        End With
        'Load Search Array
        With Sheets(SearchSheetName)
            searchArray = .Range(.Range(SearchSheetColumn & "1"), _
                    .Range(SearchSheetColumn & Rows.Count).End(xlUp))
        End With
    
    
        Dim dict As Object
        Set dict = CreateObject("Scripting.Dictionary")
        'Populate dictionary from search array
        If IsArray(searchArray) Then
            For x = 1 To UBound(searchArray)
                If Not dict.exists(searchArray(x, 1)) Then
                    dict.Add searchArray(x, 1), 1
                End If
            Next
        Else
            If Not dict.exists(searchArray) Then
                dict.Add searchArray, 1
            End If
        End If
    
        'Delete rows with values found in dictionary
        If IsArray(targetArray) Then
            'Step backwards to avoid deleting the wrong rows.
            For x = UBound(targetArray) To 1 Step -1
                If dict.exists(targetArray(x, 1)) Then
                    targetRange.Cells(x).EntireRow.Delete
                End If
            Next
        Else
            If dict.exists(targetArray) Then
                targetRange.EntireRow.Delete
            End If
        End If
    End Sub

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Excel Runtime Error 429 in VBA on MAC

    Untested
    Sub CleanDupes()
        Dim targetArray, searchArray
        Dim targetRange As Range
        Dim x As Long
    
        'Update these 4 lines if your target and search ranges change
        Dim TargetSheetName As String: TargetSheetName = "New list"
        Dim TargetSheetColumn As String: TargetSheetColumn = "A"
        Dim SearchSheetName As String: SearchSheetName = "Unsubscribes"
        Dim SearchSheetColumn As String: SearchSheetColumn = "A"
    
        'Load target array
        With Sheets(TargetSheetName)
            Set targetRange = .Range(.Range(TargetSheetColumn & "1"), _
                    .Range(TargetSheetColumn & Rows.Count).End(xlUp)).Resize(, 2)
            targetArray = targetRange
        End With
        'Load Search Array
        With Sheets(SearchSheetName)
            searchArray = .Range(.Range(SearchSheetColumn & "1"), _
                    .Range(SearchSheetColumn & Rows.Count).End(xlUp)).Resize(, 2)
        End With
        Dim col As Collection, s
        Set col = New Collection
        On Error Resume Next
        For x = 1 To UBound(searchArray)
            col.Add searchArray(x, 1), CStr(searchArray(x, 1))
        Next
        For x = UBound(targetArray) To 1 Step -1
            Err.Clear
            s = col(CStr(targetArray(x, 1)))
            If Err.Number <> 0 Then targetRange.Cells(x).EntireRow.Delete
        Next
        On Error GoTo 0
    End Sub
    However, I think autofilter will do the same and faster...

+ 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. Runtime Error when running Excel VBA
    By kingsdime29x in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-23-2023, 12:27 PM
  2. [SOLVED] runtime error in Excel VBA
    By tdf2437 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-16-2017, 04:09 PM
  3. Excel VBA Runtime 1004 Error
    By darian117 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-04-2012, 01:41 PM
  4. Excel xmlHTTP object error message - system/runtime error
    By Porky2007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-23-2007, 09:36 AM
  5. Runtime Error 1004 Excel 97
    By missfitz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2006, 04:06 AM
  6. Excel 2003 Macro Error - Runtime error 1004
    By Cow in forum Excel General
    Replies: 2
    Last Post: 06-07-2005, 09:05 AM
  7. [SOLVED] Excel help giving runtime error
    By Hari Prasadh in forum Excel General
    Replies: 2
    Last Post: 01-24-2005, 05:06 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