Autofill Item name based on ID item in Excel VBA Userform

liaaa

New Member
Joined
Sep 29, 2023
Messages
20
Office Version
  1. 2010
Platform
  1. Windows
Hello,
So I try to make a userform. The user only needs to fill in the ID item (column H) and the item name (column I) will be filled automatically. Is this possible for multiple ID ITEM in one textbox? So user will input multiple ID Items and then the Item name will be filled automatically. Or is there another alternative to do this?
1697554263332.png

1697554323910.png


This is the link for the file

Thank you for your help :)
 
yeah, i already tried it, it's working. But The input box appears for both items that have an ID and do not have an ID. I tried to input ID 317177 (this ID exists in the ITEM sheet) and ID 12345 (this ID doesn't exist in the ITEM sheet) and the input box appears twice for each ID that I input. The input box should only appear for item ID that are not in the ITEM sheet, right?
 
Upvote 0

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Yes,
VBA Code:
IsError(Application.Match(IDITEM(j), Worksheets("ITEM").Range("A:A"), 0))
This means "if it can't match any items in colunm A".
Maybe you have extra spaces before or after the IDs. Check the ITEM sheet for this issue.

Also if you input ID's like 123, 456, 789, because you seperate them by only comma, they will leave extra space before numbers. What I mean is, your array will look like "123", " 456", " 789". I hope you got it. Anyway, it is easy to fix. Seperate your values only with comma, no spaces or what so ever. I am also adding a safety measure to prevent future insidances:
VBA Code:
    If IsError(Application.Match(Trim(IDITEM(j)), Worksheets("ITEM").Range("A:A"), 0)) Then
        itemName = InputBox("Please provide Item Name for ID: " & IDITEM(j))
    Else
        itemName = Worksheets("ITEM").Cells(Application.Match(Trim(IDITEM(j)), Worksheets("ITEM").Range("A:A"), 0), "B").Value
    End If
 
Upvote 0
Hi,
Sorry for the late response. Your code works perfectly as I expected. Once again thank you very much for all your help :)
 
Upvote 0
I am glad it did work (y)
As I told you, don't forget to clear leading or trailing spaces in Sheet ITEM Column ID.
Also, avoid inputs other than commas in the textbox. Have a nice day :)
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top