ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Elseif code (https://www.excelbanter.com/excel-programming/321213-elseif-code.html)

HFB

Elseif code
 
I have:
3 combo boxes for specifying jamb profile
1 text box for specifying alternative jamb profile
1 text box for entering the width of the stud
1 text box for displaying the width of the jamb

I need the Jamb Width text box to display a value based on what is in the
jamb profile boxes and the stud box. Only one of the boxes will display a
jamb profile (e.g. if one combo box is displaying "18mm Flat" then all the
others will be "")

Basically

If Jamb Profile = "18mm Flat", "Flat", "Arch" or "Architrave", then
Jamb Width = Stud Width +22

Else Jamb Width = Stud Width + 45

I've go the following code:
'DEFINE VARIABLES
Dim Jamb As Integer
Dim Stud As Integer
Dim comFPine As String
Dim ComCPine As String
Dim ComMUF As String
Dim txtProfileSpec As String

'INPUT

Stud = Val(txtStud1)

'PROCESS
'If Profile is Architrave, then Jamb = Stud + 22
'If Profile is Grooved, then Jamb = Stud + 45

If comFPine = "18mm Flat" Then
Jamb = Stud + 22
ElseIf ComCPine = "18mm Flat" Then
Jamb = Stud + 22
ElseIf ComMUF = "18mm Flat" Then
Jamb = Stud + 22
ElseIf txtProfileSpec = "Flat" Then
Jamb = Stud + 22
ElseIf txtProfileSpec = "Architrave" Then
Jamb = Stud + 22
ElseIf txtProfileSpec = "Arch" Then
Jamb = Stud + 22

Else: Jamb = Stud + 45
End If


'OUTPUT
txtJamb1 = Str(Jamb)

At the moment, all that does is the "Stud Width + 45" Part :)



gocush[_29_]

Elseif code
 
Instead of using vba to sort out all the possibilities you might want to make
a table on a worksheet with all the possible configuations.
Then have your comboboxes with the list fill range set to columns in your
table

When you want to have the 2nd combobox filled with items that vary depending
on what the user selected in the 1st combobox, there is a good demo of how to
do this at : http://contextures.com/xlDataVal02.html

Hope this helps

"HFB" wrote:

I have:
3 combo boxes for specifying jamb profile
1 text box for specifying alternative jamb profile
1 text box for entering the width of the stud
1 text box for displaying the width of the jamb

I need the Jamb Width text box to display a value based on what is in the
jamb profile boxes and the stud box. Only one of the boxes will display a
jamb profile (e.g. if one combo box is displaying "18mm Flat" then all the
others will be "")

Basically

If Jamb Profile = "18mm Flat", "Flat", "Arch" or "Architrave", then
Jamb Width = Stud Width +22

Else Jamb Width = Stud Width + 45

I've go the following code:
'DEFINE VARIABLES
Dim Jamb As Integer
Dim Stud As Integer
Dim comFPine As String
Dim ComCPine As String
Dim ComMUF As String
Dim txtProfileSpec As String

'INPUT

Stud = Val(txtStud1)

'PROCESS
'If Profile is Architrave, then Jamb = Stud + 22
'If Profile is Grooved, then Jamb = Stud + 45

If comFPine = "18mm Flat" Then
Jamb = Stud + 22
ElseIf ComCPine = "18mm Flat" Then
Jamb = Stud + 22
ElseIf ComMUF = "18mm Flat" Then
Jamb = Stud + 22
ElseIf txtProfileSpec = "Flat" Then
Jamb = Stud + 22
ElseIf txtProfileSpec = "Architrave" Then
Jamb = Stud + 22
ElseIf txtProfileSpec = "Arch" Then
Jamb = Stud + 22

Else: Jamb = Stud + 45
End If


'OUTPUT
txtJamb1 = Str(Jamb)

At the moment, all that does is the "Stud Width + 45" Part :)




All times are GMT +1. The time now is 09:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com