+ Reply to Thread
Results 1 to 5 of 5

VBA macro not running. Finding duplicates macro

Hybrid View

  1. #1
    Registered User
    Join Date
    11-08-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    46

    VBA macro not running. Finding duplicates macro

    Here is a formula that I cannot get working anymore. I used it 2 years ago and I don't remember how it works.

    This formula has to detects duplicates from column A and has to mark same duplicates with specific number in the next column

    Formula: copy to clipboard
    Sub duplicates()
    Dim OCell As Range, ProductInfo As Range
    Dim FirstAddress As String
    Dim i As Integer, u As Integer, ProdCount As Integer
    Application.ScreenUpdating = False

    u = 1
    Range("A:A").Activate
    With ActiveSheet

    Do Until ActiveCell = ""

    If ActiveCell.Offset(0, 1) <> "" Then
    Do
    ActiveCell.Offset(1, 0).Activate
    Loop Until ActiveCell.Offset(0, 1) = ""

    FirstAddress = ActiveCell.Address
    Range(FirstAddress).Activate
    End If

    Set ProductInfo = ActiveCell
    FirstAddress = ActiveCell.Address

    With .Columns("A:A")
    ProdCount = WorksheetFunction.CountIf(.Columns("A:A"), ProductInfo)

    If ProdCount > 1 Then
    Set OCell = .Find(ProductInfo.Value, LookAt:=xlWhole)
    OCell.Activate
    ActiveCell.Offset(0, 1) = u
    For i = 1 To ProdCount - 1
    Set OCell = .FindNext(OCell)
    OCell.Activate
    ActiveCell.Offset(0, 1) = u
    Next i
    u = u + 1
    Else
    Range(FirstAddress).Offset(1, 0).Activate
    End If
    End With
    10

    Set OCell = Nothing
    ProdCount = 0
    Range(FirstAddress).Offset(1, 0).Activate
    Loop
    End With
    Range("A:A").Select
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    Set ProductInfo = Nothing
    Set OCell = Nothing
    End Sub

  2. #2
    Registered User
    Join Date
    11-08-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: VBA macro not running. Finding duplicates macro

    Problem is with the type of text in column A. This formula is working for alphabetic letter. I need it to work with number (phone numbers)

    Workbook8.xlsx

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VBA macro not running. Finding duplicates macro

    Sub HelpExc()
    Dim d As Object:    Set d = CreateObject("Scripting.Dictionary")
    Dim ws As Worksheet:    Set ws = Sheets("Sheet1")
    Dim i As Long
    
    For i = 1 To ws.Range("A" & Rows.Count).End(xlUp).Row
        If d.Exists(ws.Range("A" & i).Value) Then
            ws.Range("B" & i).Value = d.Item(ws.Range("A" & i).Value)
            d.Item(ws.Range("A" & i).Value) = CLng(d.Item(ws.Range("A" & i).Value) + 1)
        Else
            d.Item(ws.Range("A" & i).Value) = 1
        End If
    Next i
    
    End Sub
    If you are happy with my response please click the * in the lower left of my post.

  4. #4
    Registered User
    Join Date
    11-08-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: VBA macro not running. Finding duplicates macro

    Thanks. One question, I'm getting debug error 429

    Screen Shot 2016-01-08 at 10.45.37.png

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VBA macro not running. Finding duplicates macro

    Are you using the Mac version of excel?

+ 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. Macro template good saved but running macro with imported data problem
    By brazilexcel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-18-2015, 10:42 PM
  2. Replies: 5
    Last Post: 12-19-2014, 01:31 AM
  3. Replies: 0
    Last Post: 09-23-2014, 02:13 PM
  4. [SOLVED] Macro to find duplicates, concatenate Unique Values, then delete old duplicates
    By lesoies in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-17-2013, 04:32 PM
  5. [SOLVED] Macro for finding duplicates then deleting the row
    By adamj1910 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-17-2012, 04:11 AM
  6. Replies: 7
    Last Post: 07-28-2011, 11:11 AM
  7. Cannot find macro error when running a macro from a macro in a diffrent workbook.
    By Acrobatic82 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2010, 09:22 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