+ Reply to Thread
Results 1 to 9 of 9

MsgBox Text Based on Value entered in UserForm (Vlookup?)

  1. #1
    Registered User
    Join Date
    03-17-2015
    Location
    South Carolina, USA
    MS-Off Ver
    2010
    Posts
    59

    MsgBox Text Based on Value entered in UserForm (Vlookup?)

    Hello all,

    New user here. I have been searching far and wide for a solution to this problem. I am new to macros, but have been gaining knowledge from searching forums like this one. This is the first time I have felt completely stuck.

    I am attempting to use VLookup to place a value in a msgbox based on the value entered in a user form.

    Here is what I have so far: (I have tried 100's of different variations of this. sub is ran by a command button)

    Please Login or Register  to view this content.
    I get only errors.

    My end goal is to have an If statement so that if the item typed in does not exist I get:

    Please Login or Register  to view this content.
    My Item Number is in column A and the quantity is in column B.

    Thanks in advance for your help!

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: MsgBox Text Based on Value entered in UserForm (Vlookup?)

    in which module is this code and where is textbox1 this si my first question
    and second pretty importatnt is are ItemNumbers real numbers ? text box value is text type so vlookup "number" in numbers will fail. so may be ...VLookup(val(TextBox1.Value), ... would do
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    03-17-2015
    Location
    South Carolina, USA
    MS-Off Ver
    2010
    Posts
    59

    Re: MsgBox Text Based on Value entered in UserForm (Vlookup?)

    Thanks,

    I tried:
    Please Login or Register  to view this content.
    With no luck.

    Sub EditAdd() is located on a new module I inserted.
    TextBox1 is located on UserForm1

    Regards,

    Carl

  4. #4
    Registered User
    Join Date
    03-17-2015
    Location
    South Carolina, USA
    MS-Off Ver
    2010
    Posts
    59

    Re: MsgBox Text Based on Value entered in UserForm (Vlookup?)

    Here is a simple version of my file. I have only one record in the "Inventory" Sheet.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-17-2015
    Location
    South Carolina, USA
    MS-Off Ver
    2010
    Posts
    59

    Re: MsgBox Text Based on Value entered in UserForm (Vlookup?)

    This is mind blowing to me. It seems so simple. I must be missing something...

    I got closer, but no cigar:

    Please Login or Register  to view this content.
    Thanks for any additional help.

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: MsgBox Text Based on Value entered in UserForm (Vlookup?)

    That was exactly my first part of question - as your Sub is in standard module, it knows nothing about such object as TextBox1.
    So either let vba know where to look for textbox1:

    Please Login or Register  to view this content.
    or (suggested solution) move your whole Sub EditAdd() to userform1 code (where for instance your Private Sub CommandButton5_Click() resides)

    PS. Working with vlookup this way can easily cause execution time errors (when no itemnumber is found in column A) - so some error handling would be wise idea like (version to be inserted in UserForm code (for standard module remember about Userform1. prefix)
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-17-2015
    Location
    South Carolina, USA
    MS-Off Ver
    2010
    Posts
    59

    Re: MsgBox Text Based on Value entered in UserForm (Vlookup?)

    Inventory Control.xlsm

    So very close.

    THANK YOU!!!

    It is working and returns the msgbox how I want.

    However, it is giving me the error that it doesn't exist after I accept the msgbox.

    How can I fix this? (See attachment)

    Regards,

    Carl

  8. #8
    Registered User
    Join Date
    03-17-2015
    Location
    South Carolina, USA
    MS-Off Ver
    2010
    Posts
    59

    Re: MsgBox Text Based on Value entered in UserForm (Vlookup?)

    Closer Still, I will figure this out.
    \
    Thanks for the help!
    Please Login or Register  to view this content.
    Last edited by silentcarl; 03-18-2015 at 08:07 AM.

  9. #9
    Registered User
    Join Date
    03-17-2015
    Location
    South Carolina, USA
    MS-Off Ver
    2010
    Posts
    59

    Re: MsgBox Text Based on Value entered in UserForm (Vlookup?)

    Please Login or Register  to view this content.
    That did it.

+ 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. Display msgbox when specific text entered in specific range
    By Ali_Riza in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-20-2012, 08:05 AM
  2. [SOLVED] Validate Userform Text Box against data already entered
    By dieseldogpi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2012, 11:40 AM
  3. Code to perform task based on data entered in userform
    By Staci in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-27-2011, 02:06 PM
  4. Concatenate text and checkbox data entered in userform
    By Samantha McNeill in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2011, 02:43 PM
  5. Vlookup macro based on 2 values returning msgbox
    By bd528 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-07-2010, 09:16 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