+ Reply to Thread
Results 1 to 8 of 8

Automatically adding names to list

Hybrid View

HarleyRider Automatically adding names to... 12-31-2017, 12:42 PM
AliGW Re: Automatically adding... 12-31-2017, 12:42 PM
Glenn Kennedy Re: Automatically adding... 12-31-2017, 12:43 PM
HarleyRider Re: Automatically adding... 12-31-2017, 01:17 PM
bakerman2 Re: Automatically adding... 01-01-2018, 04:07 AM
HarleyRider Re: Automatically adding... 01-01-2018, 03:34 PM
bakerman2 Re: Automatically adding... 01-01-2018, 07:26 PM
josephteh Re: Automatically adding... 01-01-2018, 11:24 PM
  1. #1
    Registered User
    Join Date
    08-29-2012
    Location
    Pensacola, Fl
    MS-Off Ver
    Excel 2021
    Posts
    36

    Automatically adding names to list

    I run a football pickem contest and have been working on collecting some historical data. I have a sheet in the workbook called "Year Sort" that has each year of the game in separate columns across the sheet. I then have a page called Players-annual scores where I have an alphabetical list of all players. We have new players every year, and what I'm trying to do is get Excel to recognize a name that is NOT on the Annual Scores list and automatically insert that name into the list. It would be nice if it would sort alphabetically as well but that's not a must have. I'm attaching some pictures of what I am using to make it easier to understand. Thanks for any help anybody can provide
    Attached Images Attached Images

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,492

    Re: Automatically adding names to list

    Will you please attach a sample Excel workbook? We are not able to work with or manipulate a picture of one and nobody wants to have to recreate your data from scratch.

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired results are also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Automatically adding names to list

    Blurry pictures aren't any use.

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? Please don't attach a picture of one (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential information is removed first!!

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  4. #4
    Registered User
    Join Date
    08-29-2012
    Location
    Pensacola, Fl
    MS-Off Ver
    Excel 2021
    Posts
    36

    Re: Automatically adding names to list

    attached workbook. There's nothing in it that is secret or anything. It's just a list of names with scores that likely won't matter to anybody but me. Thanks for the help.
    Attached Files Attached Files

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,300

    Re: Automatically adding names to list

    This is just straight forward.
    It compares year 2016 column on sheet year sort with names on players annual and adds names that are missing.
    Sub tst()
        Set dic = CreateObject("scripting.dictionary")
        With Sheets("Players-annual scores")
            sn = .Range("B3", .Range("B" & .Rows.Count).End(xlUp))
        End With
        For i = 1 To UBound(sn)
            x0 = dic.Item(sn(i, 1))
        Next
        With Sheets("YearSort")
            sn2 = .Range("AF4", .Range("AF" & .Rows.Count).End(xlUp))
        End With
        For i = 1 To UBound(sn2)
            If Not dic.exists(sn2(i, 1)) Then
                With Sheets("Players-annual scores")
                    .Range("B" & .Rows.Count).End(xlUp).Offset(1).EntireRow.Insert
                    .Range("B" & .Rows.Count).End(xlUp).Offset(1) = sn2(i, 1)
                End With
            End If
        Next
    End Sub
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  6. #6
    Registered User
    Join Date
    08-29-2012
    Location
    Pensacola, Fl
    MS-Off Ver
    Excel 2021
    Posts
    36

    Re: Automatically adding names to list

    Quote Originally Posted by bakerman2 View Post
    This is just straight forward.
    It compares year 2016 column on sheet year sort with names on players annual and adds names that are missing.
    Sub tst()
        Set dic = CreateObject("scripting.dictionary")
        With Sheets("Players-annual scores")
            sn = .Range("B3", .Range("B" & .Rows.Count).End(xlUp))
        End With
        For i = 1 To UBound(sn)
            x0 = dic.Item(sn(i, 1))
        Next
        With Sheets("YearSort")
            sn2 = .Range("AF4", .Range("AF" & .Rows.Count).End(xlUp))
        End With
        For i = 1 To UBound(sn2)
            If Not dic.exists(sn2(i, 1)) Then
                With Sheets("Players-annual scores")
                    .Range("B" & .Rows.Count).End(xlUp).Offset(1).EntireRow.Insert
                    .Range("B" & .Rows.Count).End(xlUp).Offset(1) = sn2(i, 1)
                End With
            End If
        Next
    End Sub
    so this is a macro that I can include that will solve the name problem. You specifically mentioned 2016, but I need this to work with each year and future years as I had results to it. Is this going to grab names missing from each year and put them on the sheet?

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,300

    Re: Automatically adding names to list

    This one will give you a sorted list of all unique names on yearsort and put result on players annual column W.
    The only thing you have to do is copy and paste result in Column B ofplayers annual.
    Sub test()
        Dim e, numcol As Long
        With CreateObject("System.Collections.ArrayList")
            numcol = Sheets("YearSort").UsedRange.Columns.Count
            For i = 2 To numcol Step 3
                For Each e In Sheets("YearSort").Columns(i).Value
                    If e <> "" Then
                        If Not IsNumeric(e) Then
                            If Not .Contains(e) Then .Add e
                        End If
                    End If
                Next
            Next
            .Sort
            Sheets("Players-annual scores").Columns(23).ClearContents
            Sheets("Players-annual scores").Range("W4").Resize(.Count).Value = Application.Transpose(.ToArray)
        End With
    End Sub

  8. #8
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Automatically adding names to list

    Use PivotTable... but first, reformat your data and format it as a table.
    Attached Files Attached Files

+ 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. Adding a dropdown list of names
    By AdamHaubert in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-10-2013, 10:54 AM
  2. [SOLVED] Search a list of names and automatically return any names not already included in table
    By bishbash89 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-21-2013, 09:06 AM
  3. Automatically adding names to a calendar.
    By brine in forum Excel General
    Replies: 0
    Last Post: 07-14-2011, 02:52 PM
  4. adding commas to list of names
    By Jeanapeana in forum Excel General
    Replies: 6
    Last Post: 07-12-2010, 02:47 AM
  5. Automatically add names (text) to a list
    By JOGIER in forum Excel General
    Replies: 2
    Last Post: 03-27-2009, 01:14 PM
  6. Replies: 3
    Last Post: 05-06-2008, 03:15 PM
  7. Automatically adding IDs next to names
    By ysbn in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-17-2007, 07:20 AM
  8. Adding Sheets with names from a list.
    By Casey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-04-2006, 11:31 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