+ Reply to Thread
Results 1 to 8 of 8

Locate Column that only has one value in excel

Hybrid View

  1. #1
    Registered User
    Join Date
    10-10-2018
    Location
    Los Angeles
    MS-Off Ver
    2013
    Posts
    3

    Re: Locate Column that only has one value in excel

    NickyC - Thats works but I want the opposite of it. I want to locate the column(s) that only has a single (distinct) value all across that column. That means that has 1 value Rob in all the cells in that column.

    This formula is looking for all blank columns in the spreadsheet. I want the columns that has a single(Distinct) value in the spreadsheet.

    Locate a column where the vale remains same in all cells and doesn't change. Hope this explanation helps.

    Admin - I can't find the button for attaching a dummy file.
    Attached Files Attached Files
    Last edited by deephouse; 10-11-2018 at 03:43 PM. Reason: Attaching a Dummy Excel file

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Locate Column that only has one value in excel

    ok try this:

    Sub FindOnes()
    Dim MyRg As Range, CCol As Range, CCell As Range, MyVal, ColC As String, IsDups As Boolean
    Set MyRg = ActiveSheet.UsedRange
    ColC = ""
    For Each CCol In MyRg.Columns
        MyVal = ""
        IsDups = True
        For Each CCell In CCol.Cells
            If CCell.Row <> 1 And MyVal = "" And CCell <> "" Then MyVal = CCell
            If CCell.Row <> 1 And CCell <> MyVal And CCell <> "" Then
                IsDups = False
                GoTo nXtC
            End If
        Next CCell
        If IsDups = True And MyVal <> "" Then ColC = ColC & " " & CCol.Cells(1).Address(0, 0)
    nXtC:
    Next CCol
    If ColC <> "" Then MsgBox "these columns have duplicate values:" & Replace(ColC, 1, "") Else MsgBox "no columns have duplicate values"
    End Sub

  3. #3
    Registered User
    Join Date
    10-10-2018
    Location
    Los Angeles
    MS-Off Ver
    2013
    Posts
    3

    Re: Locate Column that only has one value in excel

    This works, thanks NickyC. You are awesome!!

+ 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. Replies: 7
    Last Post: 01-25-2018, 08:06 PM
  2. Locate all the instances of a list of values in one column in another column
    By norwoodkd2001 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-01-2015, 09:52 AM
  3. [SOLVED] Locate first cell in column
    By cmb80 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-05-2015, 05:02 AM
  4. macro to locate locate text string and copy/paste offset range
    By guystanley in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-16-2014, 08:46 PM
  5. Locate Column through Excel ODBC
    By r1012 in forum Access Tables & Databases
    Replies: 0
    Last Post: 10-16-2012, 07:09 PM
  6. Locate max number from column A
    By vba-lover in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2007, 08:24 AM
  7. About locate last cell in the last column
    By bobocat in forum Excel General
    Replies: 7
    Last Post: 07-03-2006, 10:45 PM

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