Custom Worksheet

jwbatey07

New Member
Joined
Apr 14, 2020
Messages
33
Office Version
  1. 365
Platform
  1. Windows
I am working on building a custom worksheet for our operation. We build custom hose assemblies and there are thousands of combinations depending on the hose type, hose size, pressure, and end connection. I have successfully created a form of sorts in excel. My current working form only use Selections and the Indirect function. The issue is when you change the informtion on a fields toward the top of the form it leaves the old, possible incorrect information behind. I would also like to print the information once a form is filled out then clear the fields for the next assembly. I've stumbled on VBA and have attempted to create a cleaner and more functional form in Visual Basic. I've been able to create some of the beginning comboboxs I'm going to need. Once i get past the second combobox everything starts to go south. Unfortunately, the raw data is not the neatest nor is it simple.

THE Sample of the form
HOSE TYPESIZEHOSE TYPEHOSE SELECTION
HYDRAULICHYD_4HYD_4_DOUBLEHB6K_4
FITTING TYPE 1FITTING TYPE 2
JIC_4_SER_2NPT_4_SER_2
FITTING 1 FITTING 2
F2-0406-JFSF2-0404-PF
FERRULE TYPEFERRULE 2
NONE NEEDEDNONE NEEDED
FERRULE 1FERRULE 2
400_B380_B



THE CODE
Private Sub ComboBox1_Click()
Dim x As Integer
x = ComboBox1.ListIndex

Select Case x
Case Is = 0
ComboBox2.RowSource = "Hydraulic"
Case Is = 1
ComboBox2.RowSource = "air_or_water"
Case Is = 2
ComboBox2.RowSource = "fuel"
Case Is = 3
ComboBox2.RowSource = "ac"
Case Is = 4
ComboBox2.RowSource = "ptfe"

End Select

End Sub



Private Sub ComboBox2_Click()
Dim x As Integer
x = ComboBox2.ListIndex



Select Case x
Case Is = 0
ComboBox3.RowSource = "hyd_3"
Case Is = 1
ComboBox3.RowSource = "hyd_4"
Case Is = 2
ComboBox3.RowSource = "hyd_6"
Case Is = 3
ComboBox3.RowSource = "hyd_8"
Case Is = 4
ComboBox3.RowSource = "hyd_10"
Case Is = 5
ComboBox3.RowSource = "hyd_12"
Case Is = 6
ComboBox3.RowSource = "hyd_16"
Case Is = 7
ComboBox3.RowSource = "hyd_20"
Case Is = 8
ComboBox3.RowSource = "hyd_24"
Case Is = 9
ComboBox3.RowSource = "hyd_32"
Case Is = 10
ComboBox3.RowSource = "air_4"



End Select



End Sub



Private Sub ComboBox3_Click()

Dim x As Integer
x = ComboBox3.ListIndex

Select Case x
Case Is = 0
ComboBox4.RowSource = "HYD_3"
Case Is = 1
ComboBox4.RowSource = "HYD_4_SINGLE"
Case Is = 2
ComboBox4.RowSource = "hyd_4_double"
Case Is = 3
ComboBox4.RowSource = "hyd_4_100r5"
Case Is = 4
ComboBox4.RowSource = "hyd_4_100r7_non_conductive"
Case Is = 5
ComboBox4.RowSource = "hyd_4_100r8_non_conductive"



End Select

End Sub

Private Sub UserForm_Initialize()
ComboBox1.RowSource = "type"

End Sub


THE DATA
1586890154500.png



Any help someone can give me to steer me in the right direction would be greatly appricated.

Regards,

James
 

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"
Assuming those are all named ranges you can use something like
VBA Code:
Private Sub ComboBox1_Change()
   Me.ComboBox2.Clear
   Me.ComboBox2.List = Range(Me.ComboBox1.Value).Value
End Sub
 
Upvote 0
Can i use that code for each combobox? The form will have 12 comboboxes, each combobox needs to have the range of values that is tied to the previous combobox. I have a lot of named ranges and they are all static.
1586893646866.png
 
Upvote 0
As long as the value in the combos is a named range, then you can do it for all of them. :)
Just make sure none of them use RowSource.
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
one last question. i'm having trouble with the reset command. I've tried several variations and cannot get it to execute correct.
1586969702420.png
 
Upvote 0
What do you want it to do?
 
Upvote 0
i would like to have a reset command that clears all of the comboboxes.
 
Upvote 0
How about
VBA Code:
Private Sub cmbReset_Click()
   Dim i As Long
   
   For i = 1 To 12
      Me.Controls("ComboBox" & i).Clear
   Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,473
Messages
6,125,022
Members
449,203
Latest member
tungnmqn90

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