+ Reply to Thread
Results 1 to 21 of 21

Find Number In Term & Select Case

  1. #1
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Find Number In Term & Select Case

    .
    I have a list of terms. Example:

    X3HJ
    NR4T
    JA8FG
    UV5EEE
    M0ERD

    I need a macro (not formula) that will detect the number in the string, then using that number
    guide the code to a specific additional macro designed only for that number.

    :: Air Code ::

    Please Login or Register  to view this content.
    Thank you for your assistance.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Find Number In Term & Select Case

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Find Number In Term & Select Case

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: Find Number In Term & Select Case

    .
    shg

    Tried this .. no luck. Where am I going wrong ? Says cant find Dictionary2

    Please Login or Register  to view this content.

    mehmetcik

    Thank you for your assistance as well. Says TYPE MISMATCH .. I've tried String and tried Integer ...

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Find Number In Term & Select Case


    Or just use RegExp & CallByName …

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Find Number In Term & Select Case

    Tried this .. no luck. Where am I going wrong ? Says cant find Dictionary2
    Works fine for me in a standard code module exactly as you posted it.

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: Find Number In Term & Select Case

    .
    My apologies to both of you ! I feel so dumb ......

    It really helps if you enter the correct term to begin with ! Last night I was working with previous versions that didn't have the auto-select Dictionary macro ...
    That version already has some error handling to tell a dummy like me that the term entered wasn't accurate.

    I'll just go crawl off into my hole over there in the corner and be quiet now.

    Thank you both again !


  8. #8
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: Find Number In Term & Select Case

    .
    May I ask one last question ?

    How would I go about not having the second INPUT BOX input ? Just carry over the tern entry from the first INPUT BOX.

    I'll understand if you decide not to assist this fumbling fool.

    Thanks for all you do. You guys are the best.

  9. #9
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Find Number In Term & Select Case

    I inserted a line

    entering sdsd1bcb got me dictionary 1.

    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Via RegExp …


    As a beginner starter :

    PHP Code: 
    Sub Demo4Noob()
        
    Dim S$, T$
            
    InputBox(vbLf vbLf "Term ?""  Search")
        
    With CreateObject("VBScript.RegExp")
               .
    Pattern "\d"
            
    If .Test(SThen T = .Execute(S)(0)
        
    End With
            
    If "0" And "5" Then MsgBox Application.Run("Noob" T), , S
    End Sub

    Function Noob1$()
             
    Noob1 "One step beyond …"
    End Function

    Function 
    Noob2$()
             
    Noob2 "Two Evil Eyes"
    End Function

    Function 
    Noob3$()
             
    Noob3 "Three Kings"
    End Function

    Function 
    Noob4$()
             
    Noob4 "Four Weddings and a Funeral"
    End Function 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 07-18-2018 at 07:26 PM. Reason: little optimization …

  11. #11
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: Find Number In Term & Select Case

    .
    shg

    Sorry to do this but it has gone to not recognizing the presence of the macros again ..... WTHuh ? I know ... go figure .. story of my life.

    I added in a MsgBox to see what was occurring with the macro # selection.

    I appears to be jumping around the numbers while searching for the correct TryDictionary# ??? Is it accurate what I'm seeing ?

    Try this and see if it does the same there:

    Please Login or Register  to view this content.
    Last edited by Logit; 07-18-2018 at 07:28 PM.

  12. #12
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: Via RegExp …

    .
    Marc L

    Here is my stab with the macro. Where is my error ?

    Please Login or Register  to view this content.

  13. #13
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: Find Number In Term & Select Case

    .
    To all ... so you have the same workbook as I ...
    Attached Files Attached Files

  14. #14
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Find Number In Term & Select Case

    Didn't try your workbook yet.
    Please Login or Register  to view this content.
    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.

  15. #15
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Find Number In Term & Select Case

    It works if you either use

    Please Login or Register  to view this content.
    ... or get rid of the other procedures with the same name in other modules.

  16. #16
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Find Number In Term & Select Case

    With example file.
    Attached Files Attached Files

  17. #17
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: Find Number In Term & Select Case

    .
    Thank you shg. I was thinking about that over dinner and realized my mistake.

  18. #18
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: Find Number In Term & Select Case

    .
    bakerman :

    Is there a way to eliminate having to enter the term twice .. using 2 InputBoxes ?

    Enter the term in the first InputBox and the macro runs all the way through ?

    Thank you so much !

  19. #19
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Find Number In Term & Select Case

    Please Login or Register  to view this content.

  20. #20
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: Find Number In Term & Select Case

    .
    Thank you bakeman !

  21. #21
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Find Number In Term & Select Case

    Glad to help and thanks for rep+.

+ 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: 1
    Last Post: 07-14-2016, 05:51 AM
  2. [SOLVED] Disregard case in VBA code. (UCase, LCase, Select Case)
    By Orestees in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 09-07-2012, 12:12 PM
  3. [SOLVED] Select Case Statement Alternative Large Number of Combinations
    By plasma33 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-24-2012, 06:28 AM
  4. Case Select compile error "Case without case select"
    By coasterman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2012, 06:50 AM
  5. Case Select....The alternative method for long "Select Case"
    By kimyap in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-22-2008, 01:24 AM
  6. Select Case and Find Combo - question
    By HBF in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-19-2008, 11:19 AM
  7. Use Select / Case to find certain text
    By marlea in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-02-2006, 08:05 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