Results 1 to 4 of 4

Verifying set of Values in TextBox (Userform) With Values in separate sheet using VBA

Threaded View

  1. #1
    Registered User
    Join Date
    05-20-2021
    Location
    Mississauga
    MS-Off Ver
    2016
    Posts
    27

    Question Verifying set of Values in TextBox (Userform) With Values in separate sheet using VBA

    Hello All,

    I am trying to make a fail-safe to avoid entering the wrong data in the worksheet. I will explain my Excel File (Attached) first.

    Sheet1 - "Scanned Data" -> Has 3 columns: A = Ship From, B = Serial Number, C = Part Number
    Sheet2 - "master Data" -> Has 3 columns: A = Ship From, B = Supplier Name, C = Part Number

    In "Scanned Data", I have created a User-Form to take input for A = Ship From = TextBox1, B = Serial Number = TextBox2, C = Part Number = TextBox3.

    AIM - Before entering the value in sheet 1 - the latest empty row, I want to make sure that the part number falls under the correct ship from (Supplier). This data is already present in Sheet2. Currently, I used the following logic for this purpose. But I think that logic is flawed and not in proper syntax.

    Sub Compare_Data()
        
        For i = 1 To EmptyRow
                If TextBox1.Value = Worksheets("Sheet2").Cells(i, 1).Value And TextBox3.Value = Worksheets("Sheet2").Cells(i, 3).Value Then
                    GoTo Line2
                Else
                    MsgBox "Scanned Part Does Not Match Supplier. Scan Correct Part Number"
                    TextBox3.SetFocus
                End If
            Next i
    Line2:
            
    End Sub
    In "Master Data" you can see that for the same supplier(Ship From) I have multiple products and hence I don't know how to frame this logic. You can check the current programing in my sample file, and I am ready to provide more clarification if needed.

    Would using Index and match be better? If so how to frame it.

    Thanking you in Advance.
    Attached Files Attached Files
    Last edited by General_Gin; 07-14-2021 at 01:07 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA Userform - Lookup/Match Textbox values to prefill other Textbox values
    By Lee_of_Excel in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-26-2020, 06:27 PM
  2. Auto pasting values from a reference sheet when values entered in a separate sheet.
    By jorricha in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-04-2018, 04:37 PM
  3. [SOLVED] Paste Userform textbox values into next empty cell on a sheet
    By dubcap01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-16-2015, 04:51 AM
  4. Userform to search textbox value to place other textbox values in worksheet
    By mattyh555 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-19-2012, 11:38 AM
  5. Userform: Pass textbox values to another textbox on button press
    By adjustermn in forum Word Programming / VBA / Macros
    Replies: 3
    Last Post: 02-09-2010, 11:19 PM
  6. Replies: 4
    Last Post: 06-03-2009, 04:59 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