+ Reply to Thread
Results 1 to 8 of 8

Detecting if a Form input matched a given list within the excel document

  1. #1
    Registered User
    Join Date
    01-21-2018
    Location
    Northampton, England
    MS-Off Ver
    2010
    Posts
    61

    Detecting if a Form input matched a given list within the excel document

    Hi all, Thanks in advance,

    I am trying to have the below have a section in it that when the user click out the form input, it checks to see if the input matches one of the entries within a given sheet and also matches a pre-determined formatting

    the formatting should be AAA1, but the letters and numbers can be anything from A>Z and 1>9

    The sheet for checking against will be called "Locations"

    Please Login or Register  to view this content.

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Detecting if a Form input matched a given list within the excel document

    Why not use a ComboBox with a specified drop down list. That way you can easily control what values can be selected and not have to test for formatting etc.

    BSB

  3. #3
    Registered User
    Join Date
    01-21-2018
    Location
    Northampton, England
    MS-Off Ver
    2010
    Posts
    61

    Re: Detecting if a Form input matched a given list within the excel document

    While that would work for myself, I need to make it so that someone without experience can add and remove from the listing to support those that have no VBA knowledge.

    This is to stop someone causing an error by changing something they shouldn't.

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Detecting if a Form input matched a given list within the excel document

    Hmmm... Not sure that reason is valid as users wouldn't need to go anywhere near the VBA. If the valid values for the list are to be in a range on a sheet that is accessible to all users then they would be able to add and remove values without issue. THe VBA can then apply the drop down list based on that list automatically.

    But, if you don't want to do it that way then you'll have some slightly more complicated VBA to write.

    You'll need to convert the input into uppder case, then test the current string length as the user types. If length = 1, 2 or 3 then only allow the keyasciii codes for letters A-Z, if length = 4 then only allow the keyascii for numbers 0-9. If length is greater than 4 then prevent further input before checking if the input appears in a range of accepted values and warn the user if not. Sure seems like a lot of work when a ComboBox could do all this for you.

    Happy to help you with the code if you can attach a sample workbook showing data layout for the list to compare the input against and the form layout.

    BSB

  5. #5
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Detecting if a Form input matched a given list within the excel document

    Hastily thrown together sample file attached for you to see one way of accomplishing this (still not the best solution in my opinion).

    Code used is below. It will obviously need amending so sheet and range names fit with your file.

    Please Login or Register  to view this content.
    BSB
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    01-21-2018
    Location
    Northampton, England
    MS-Off Ver
    2010
    Posts
    61

    Re: Detecting if a Form input matched a given list within the excel document

    Have sent a doc though private due to not feeling comfortable showing on main

  7. #7
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Detecting if a Form input matched a given list within the excel document

    Have you tried adapting what I attached in post #5 to fit your document? There's a working example there, gratis

    If your VBA expertise isn't quite up to scratch for adapting that then perhaps the ComboBox approach I mentioned originally WOULD be better? Might cover both your colleagues' and your skillsets.

    I'm very sorry if that sounds like an unduly harsh response (not my intention at all), but with 20+ years of Excel usage under my belt, I have a knack for spotting where the simplest option is not being utilisted. Excel, and especially the VBA side of it, is very much about the "KISS Principle".

    As mentioned earlier, happy to assist further if needed. Just let me know when and how.

    BSB
    Last edited by BadlySpelledBuoy; 12-19-2022 at 03:27 PM.

  8. #8
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,308

    Re: Detecting if a Form input matched a given list within the excel document

    @Hyperion1571, I would agree with 'BSB' apply the 'KISS Principle' , there is nothing more frustrating and time wasting than trying to guess what input is correct.
    Without sight of your actual worksheet structure it is difficult to suggest the optimum solution (again another case of that (frustrating and time wasting guesswork)).
    Help us to help you - See big yellow banner - how to upload a workbook - (we do not want to see your sensitive data, dummy data representing the actual structure and layout of the file required).
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

+ 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. Data input form, shared document
    By jlara0687 in forum Excel General
    Replies: 0
    Last Post: 11-20-2018, 06:20 PM
  2. Replies: 1
    Last Post: 09-20-2018, 04:32 AM
  3. Detecting Barcode Scanner input vs input by hand
    By Dave2018 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-12-2018, 01:20 AM
  4. Replies: 1
    Last Post: 09-04-2017, 02:11 PM
  5. Replies: 3
    Last Post: 02-27-2014, 12:06 PM
  6. Replies: 5
    Last Post: 10-01-2008, 08:30 AM
  7. Detecting Ctrl-Tabs in User Form input fields?
    By Don Wiss in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-22-2005, 10:25 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