Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 396099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:31:07+00:00 2026-05-12T16:31:07+00:00

I need a function to detect duplicates formatted as text. This cannot distinguish between

  • 0

I need a function to detect duplicates formatted as text.

This cannot distinguish between “46.500” and”46.5000″. CountIf probably compares cells as numbers. These cells are formatted as text. I tried to add an apostrophe prior the numbers.

Function check_duplicates(column As String)
LastRow = Range(column & "65536").End(xlUp).row
For x = LastRow To 1 Step -1

    If Application.WorksheetFunction.CountIf(Range(column & "1:" & column & LastRow), Range(column & x).Text) > 1 Then
        check_duplicates = x  ' return row with a duplicate
        x = 1   
    Else
         check_duplicates = 0
    End If
Next x
End Function

Does anyone know how to force CountIf to compare cells as strings or other way to check for duplicates in VBA?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:31:07+00:00Added an answer on May 12, 2026 at 4:31 pm

    I usually find ado useful in such circumstances.

    Dim cn As Object
    Dim rs As Object
    
    strFile = Workbooks(1).FullName
    strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFile _
        & ";Extended Properties=""Excel 8.0;HDR=No;IMEX=1"";"
    
    Set cn = CreateObject("ADODB.Connection")
    Set rs = CreateObject("ADODB.Recordset")
    
    cn.Open strCon
    
    strSQL = "SELECT F2, Count(F2) AS CountF2 FROM [Sheet1$] " _
      & "GROUP BY F2 HAVING Count(F2)>1 "
    rs.Open strSQL, cn
    
    s = rs.GetString
    MsgBox s
    
    '' Or
    Sheets("Sheet2").Cells(2, 1).CopyFromRecordset rs
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a graph of multi-level dependecies like this, and I need to detect
I need to detect the browser and the OS in a way like this:
One of my project need a function to detect the price change of the
I need to write a function which will detect if the input contains at
So i need a way for python to basically detect the difference between a
Can anyone help me with this... basically, I need to detect if any SVG
in function need key to encrypt string without mcrypt libraly in php function encrypt($str,
I need following function (from C++ dll) available in C++/CLI extern C _declspec(dllexport) void
I need a function that could generate a regex. For example if I write
I need some function 'apply_patch': result_string = apply_patch('origin_file.txt', 'origin_file.txt.patch') or some commands (for windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.