+ Reply to Thread
Results 1 to 21 of 21

Not Solved: Formula to match 1 or 2 columns and then from a random range upon matching

  1. #1
    Registered User
    Join Date
    11-09-2022
    Location
    West Coast, Canada
    MS-Off Ver
    365 for business
    Posts
    8

    Question Not Solved: Formula to match 1 or 2 columns and then from a random range upon matching

    Attached a new sample spreadsheet with examples, Stop removing sample fake data spreadsheet. Please read.

    ALL DATA IS FAKE from an online data generator. The Cities and Provinces are real, from the Government of Canada, the branches are from TD Bank and are public to add authenticity for testing purposes, all DATA IS NOT REAL, IT IS FAKE.

    CREDIT CARD NUMBERS FAKE, CVV FAKE. Hopefully people will read before removing sample fake data worksheet.

    NAMES AND ADDRESSES GENERATED FROM A FAKE GENERATOR, REMOVED OUT OF SAMPLE AS NOT NEEDED. PM me as I created a code that combines First and Last Name, has modifiers between including "-", "_" and "." as well as 12 different numbers, and 13 different email service providers. Unable to post here as I am too new and it keeps giving me an error in my submission.

    It is the Routing Number and Transit number I am looking for in the Transactions Worksheet.

    STATING IT AGAIN, ALL DATA IS FAKE


    Excel spreadsheet with over 50,000 rows, two worksheets, first one is called Transactions, second is called Branches

    I am trying to find the routing number and transit number where the Province and City match, however:

    IF the Province matches and the City is not found, a random city chosen, if there are multiple branches in that city, then a random branch is pulled.

    IF the Province and the City match, a random branch is chosen if there is more than 1 branch in the city.

    Named Ranges: each Province has a named Range in Branches: BRITISHCOLUMBIA,ALBERTA,SASKATCHEWAN


    Column Routing/Transit Number is blank in the Transactions worksheet, a random Branch would come from the Branches worksheet

    A random Branch would be generated from the Province of British Columbia and the City matching Vancouver, this City has 81 Branches, so let's say randomly it pulls the branch located at Coal Harbour, 494400-94400 would be pulled into the column*Routing/Transit Number in the Transactions Worksheet.


    I tried, #REF error, so I know I have it wrong. Tried VLOOKUP, but want to be able to choose a RANDOM branch if the City has more than one/

    *=INDEX(INDIRECT(VLOOKUP(G2,ALLPROVINCES,'Branches'!$D$2:$F$2526,4,FALSE)),RANDBETWEEN(1,COUNTA(INDIRECT(VLOOKUP(D2,ALLPROVINCES$D$2:$D$2526,2,FALSE)))))
    Attached Files Attached Files
    Last edited by ecomkid; 11-11-2022 at 09:30 PM. Reason: Edited to sate the obvious, data is FAKE.

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,496

    Re: Help: Formula to match 1 or 2 columns and then from a random range upon matching

    your description, a bit long and a bit convoluted, doesn't match your workbook. col F in both tabs contain a city. There is no formula in you workbook. the "example" you mention about Anne and randomly pulling "Coal Harbour", Coal Harbour is not in either workbook, neither is Anne.
    Perhaps you could upload another workbook that not only contains examples matching your description you could also include an example of your expected results and where they would come from.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    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
    52,926

    Re: Help: Formula to match 1 or 2 columns and then from a random range upon matching

    ecomkid I have removed your attachment as it appears to contain real personal data.

    If the data is actually dummy data, then please repost. otherwise replace the real data with dummy data. This is a public forum and is not the place to post real personal; data.
    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

  4. #4
    Registered User
    Join Date
    11-09-2022
    Location
    West Coast, Canada
    MS-Off Ver
    365 for business
    Posts
    8

    Re: Help: Formula to match 1 or 2 columns and then from a random range upon matching

    DATA IS FAKE

    Credit card numbers generated from Generator data.
    People and addresses generated from a name and address generator

    Cities and Provinces real, TD branches real from a public site.

    Please stop removing sample data, which was only to clarify the problem on the page.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,476

    Re: Help: Formula to match 1 or 2 columns and then from a random range upon matching

    We have a duty to protect real people, and there was no way of knowing that this data was fake. Had you told us in the opening post that this data was artificially generated, then it would have been fine. Pleae bear this in mind in future.

    You can reattach the workbook to your post.
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Registered User
    Join Date
    11-09-2022
    Location
    West Coast, Canada
    MS-Off Ver
    365 for business
    Posts
    8

    Re: Help: Formula to match 1 or 2 columns and then from a random range upon matching

    STATED IN FIRST PARAGRAPH
    Generating fake data for our software, the Users, Addresses, Credit Card numbers, Postal Codes, CVV, Amounts, and Provinces are fake, the Cities were generated from real data pulled from the Government of Canada.
    Last edited by AliGW; 11-10-2022 at 06:09 AM. Reason: Please DON'T quote unnecessarily!

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,476

    Re: Help: Formula to match 1 or 2 columns and then from a random range upon matching

    Point taken, but at least three of us missed it completely (one mod, one member who reported it and was concerened, and me). Your opening post is very wordy (nothing wrong with that), so important information like that needs to stand out.

    I'll have a look at your workbook now.

    EDIT: Your sample workbook is missing expected results - please fill these in manually for 5-10 rows in the results sheet so that we can see what we are aiming for. Thanks.

  8. #8
    Registered User
    Join Date
    11-09-2022
    Location
    West Coast, Canada
    MS-Off Ver
    365 for business
    Posts
    8

    Re: Help: Formula to match 1 or 2 columns and then from a random range upon matching

    Removed samples, clarified more, added fake data sample worksheet with Named Ranges. Hopefully this removes any confusion.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,476

    Re: Help: Formula to match 1 or 2 columns and then from a random range upon matching

    Sorry, but there are still no example results:

    AliGW on MS365 Beta Channel (Windows 11) 64 bit

    K
    L
    M
    N
    1
    Card Type
    Card Number
    CVV
    TRANSACTION-ROUTING NUMBER
    2
    Visa 4539822499742680
    633
    ?
    3
    Visa 4556584585542
    354
    ?
    4
    Visa 4916763263545
    296
    ?
    5
    Visa 4929783393457
    503
    ?
    Sheet: Transactions

    Seeing what you are aiming for will help to consolidate what you are describing in your opening post.

  10. #10
    Registered User
    Join Date
    11-09-2022
    Location
    West Coast, Canada
    MS-Off Ver
    365 for business
    Posts
    8

    Re: Help: Formula to match 1 or 2 columns and then from a random range upon matching

    Added examples in worksheet with explanation, hope this helps. Thank you.
    Last edited by AliGW; 11-10-2022 at 06:45 AM. Reason: Please DON'T quote unnecessarily!

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,476

    Re: Help: Formula to match 1 or 2 columns and then from a random range upon matching

    Thanks - I'll have another look shortly.

    In your VM to me you shared this formula that you used to generate fake E-mail addresses. I am sharing it here, as it may be useful to others.

    =A2&(CHOOSE(RANDBETWEEN(1,3),".","-","_")&B2&(CHOOSE(RANDBETWEEN(1,10),"123","456","789","223","445","4152","991","862","742","6234")&"@"&(CHOOSE(RANDBETWEEN(1,10),"aol.com","gmail.com","gmx.com","icloud.com","hotmail.com","outlook.com","protonmail.com","yandex.com","zoho.com","zohomail.com")))

  12. #12
    Registered User
    Join Date
    11-09-2022
    Location
    West Coast, Canada
    MS-Off Ver
    365 for business
    Posts
    8

    Re: Help: Formula to match 1 or 2 columns and then from a random range upon matching

    Out of 150,000 names generated from the name generator, the email addresses generated online, over 90,000 were duplicates, with the formula I created, only 232 were duplicates, which means I changed a few randomly generated numbers on 116 of them to remove the rest of the duplicates.

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,476

    Re: Help: Formula to match 1 or 2 columns and then from a random range upon matching

    I've looked at your workbook - that's much clearer now, thanks. I'm offline for a bit, but will look in again later unless someone else chips in.

  14. #14
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: Not Solved: Formula to match 1 or 2 columns and then from a random range upon matching

    the result depends on the source data
    here is the result based on existing data
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    11-09-2022
    Location
    West Coast, Canada
    MS-Off Ver
    365 for business
    Posts
    8

    Re: Not Solved: Formula to match 1 or 2 columns and then from a random range upon matching

    Looked at the Power Query, where in the code is it choosing a Random City if the Province matches, but City cannot be found. I also need to formula to choose a Random Branch if the Province and City match, but there are multiple branches in the existing City. For example Vancouver, Victoria, Edmonton, Toronto, Calgary, etc. have multiple branches, so when the Province say matches Alberta, and the City is in Calgary, a random branch would be chosen.

  16. #16
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Not Solved: Formula to match 1 or 2 columns and then from a random range upon matching

    so you will need to create random selection in source tables, unfortunately I can't help because I don't deal with formulas
    maybe someone else
    have a good day

  17. #17
    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
    52,926

    Re: Help: Formula to match 1 or 2 columns and then from a random range upon matching

    Quote Originally Posted by ecomkid View Post
    DATA IS FAKE

    Credit card numbers generated from Generator data.
    People and addresses generated from a name and address generator

    Cities and Provinces real, TD branches real from a public site.

    Please stop removing sample data, which was only to clarify the problem on the page.
    Wind your neck in, kid. I stated quite clearly...."If the data is actually dummy data, then please repost. otherwise replace the real data with dummy data."
    All you needed to do is calmly state that it was dummy data, and then repost, as suggested.

  18. #18
    Registered User
    Join Date
    11-09-2022
    Location
    West Coast, Canada
    MS-Off Ver
    365 for business
    Posts
    8

    Re: Help: Formula to match 1 or 2 columns and then from a random range upon matching

    LOL, have not been called a kid in years. Just a grumpy ol 'b' that had posted in the notes that the data was fake, so when it was removed, that was the grumpy part of my coming out wondering if anyone reads anymore. Me bolding about the data being fake was just calling attention to what I had previously stated before I edited.

  19. #19
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Not Solved: Formula to match 1 or 2 columns and then from a random range upon matching

    Could you post a whole excel file?
    if it's too big could you use OneDrive or GoogleDrive with access without logging in
    Thanks

  20. #20
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Not Solved: Formula to match 1 or 2 columns and then from a random range upon matching

    Try this as an array formula in N2 and drag down. I've put it in column P for now in the attached spreadsheet so you can see it in your format

    Please Login or Register  to view this content.
    Happy with my advice? Click on the * reputation button below

  21. #21
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Not Solved: Formula to match 1 or 2 columns and then from a random range upon matching

    Quick amendment to above. Use this to pick up the instances where there are no matches for either of the two columns. Still as an array formula

    Please Login or Register  to view this content.

+ 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. [SOLVED] Lookup formula to match a value in a range of multiple columns of another sheet
    By prettyann in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-02-2019, 07:50 AM
  2. Matching multiple columns using Match function
    By phillywilly in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-14-2018, 11:03 PM
  3. Help matching if two columns match on two different sheets
    By cjf89 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-30-2017, 01:18 PM
  4. [SOLVED] Find rows matching on 3 columns - date range; dollar range; and A or B
    By strassbergere in forum Excel General
    Replies: 0
    Last Post: 06-28-2016, 08:21 PM
  5. [SOLVED] Match formula to search range of columns to return True or False result
    By Twaddy006 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-09-2015, 05:42 PM
  6. Replies: 20
    Last Post: 05-04-2014, 03:22 PM
  7. [SOLVED] Compare columns, replace matching number with reference number and fill down random amount
    By datadigger in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-04-2012, 10:53 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