+ Reply to Thread
Results 1 to 8 of 8

Locate Column that only has one value in excel

Hybrid View

  1. #1
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,047

    Re: Locate Column that only has one value in excel

    Hi, welcome to the forum

    To best describe or illustrate your problem you would be better off attaching a dummy workbook. The workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  2. #2
    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

  3. #3
    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

  4. #4
    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