Userforms with multiple case

ncoatney

New Member
Joined
Jan 4, 2018
Messages
6
I have a userform with several text boxes. Two are tied to select case statements. What I'm after is if the defect is "sheet metal (bent)" and the reason is "bent to long" I need it to put 01001 into a cell. That part is simple enough. The problem I have is that with each defect there are several reasons, and each has it's own unique number. Other then writing multiple if and else if statements, is there an easier way to do this?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
You could conceivably set-up a lookup table of all possible combinations and use an INDEX/MATCH formula (no VBA required).

In VBA, I would probably nest the Case statements, i.e.

Code:
Select Case textBox1.Value
    Case a
        Select Case textBox2.Value
            Case aa
        ....
        End Select
    Case b
        Select Case textBox2.Value
            Case aa
        ....
        End Select
    ....
End Select
Note that unless there is some sort of pattern, duplication, or overriding values, you will probably need to spell out each option in VBA.


EDIT:
You cannot upload files to this site. But there are tools you can use to post screen images. They are listed in Section B of this link here: http://www.mrexcel.com/forum/board-a...forum-use.html. Also, there is a Test Here forum on this board that you can use to test out these tools to make sure they are working correctly before using them in your question.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
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