Consulting

Results 1 to 2 of 2

Thread: Windows to Mac macro error

  1. #1
    VBAX Regular
    Joined
    Jan 2016
    Posts
    11
    Location

    Windows to Mac macro error

    Hello there

    Im having a problem running a very simple piece of code in Excel v15.18 for Mac, that works on Windows:

    Sub RemoveDups2()
    
        Range("L18").Select
    ' L collum has a funtion =IF(K18=K19; 1;0)
    ' From L18 to end of list there are only 3 possible values
    ' 0 for ok, 1 for duplicate and nothing for end of list
    
    
        Do Until ActiveCell = ""
            ActiveCell.Offset(1, 0).Select
    
    
            If ActiveCell.Value = "1" Then .EntireRow.Delete
    
    
            End If
        Loop
    
    
    End Sub
    The error:

    Compilation error:


    invalid reference or not qualified
    (Module1 258:39)
    The error seems to happen at
    .EntireRow.Delete
    but i dont know how to fix something that should be working :P

    I also have another piece of code that could replace mine entirely, made by another user here (Thanks JKwan) that again, works on windows but not on mac:

    ption Explicit
    Sub RemoveDup()
    '
    ' RemoveDup Macro
    '
    
    
    '
    
    
        Dim Lastrow As Long
        Dim Lrow As Long
        Dim WSInput As Worksheet
         
        Set WSInput = ThisWorkbook.Worksheets("Sheet1")
        Lastrow = FindLastRow(WSInput, "D")
        On Error GoTo Dup
        With CreateObject("scripting.dictionary")
            For Lrow = Lastrow To 18 Step -1
                .Add Trim(WSInput.Cells(Lrow, "K")), Trim(WSInput.Cells(Lrow, "K"))
            Next Lrow
        End With
         
        On Error GoTo 0
        Set WSInput = Nothing
        Exit Sub
         
    Dup:
        Rows(Lrow & ":" & Lrow).Delete
        Resume Next
    End Sub
    Function FindLastRow(ByVal WS As Worksheet, ColumnLetter As String) As Long
        FindLastRow = WS.Range(ColumnLetter & Rows.Count).End(xlUp).Row
    End Function
    And in this case the error is:

    Microsoft Visual Basic

    execution time error "13":


    correspondency error

    This time the error happens at :
    Rows(Lrow & ":" & Lrow).Delete
    I assume its something to do with the .Delete parameter but, hey what do i know? xP

    Thanks in advance for the support

  2. #2
    VBAX Regular
    Joined
    Jan 2016
    Posts
    11
    Location
    fix:
    Selection.EntireRow.Delete

Posting Permissions

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