ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how do i display a value in a user form as a result of a selectio. (https://www.excelbanter.com/excel-programming/321933-how-do-i-display-value-user-form-result-selectio.html)

ptoddx1

how do i display a value in a user form as a result of a selectio.
 
I am trying to get a value to return in a label within a user form once an
option in a combobox is selected.

This is how I have tried it:

With cboTariff2

.AddItem "50006"
.AddItem "50002"
.AddItem "50005"

End With

If cboTariff2 = 50006 Then
Label74 = "£10.58"

ElseIf cboTariff2.Text = "50002" Then
Label74 = "£11.51"

ElseIf cboTariff2.Text = "50005" Then
Label74 = "£11.85"

End If

Mike Fogleman

how do i display a value in a user form as a result of a selectio.
 
Try .Value

With cboTariff2

.AddItem "50006"
.AddItem "50002"
.AddItem "50005"

End With

If cboTariff2.Value = "50006" Then
Label74 = "£10.58"

ElseIf cboTariff2.Value = "50002" Then
Label74 = "£11.51"

ElseIf cboTariff2.Value = "50005" Then
Label74 = "£11.85"

End If

Mike F
"ptoddx1" wrote in message
...
I am trying to get a value to return in a label within a user form once an
option in a combobox is selected.

This is how I have tried it:

With cboTariff2

.AddItem "50006"
.AddItem "50002"
.AddItem "50005"

End With

If cboTariff2 = 50006 Then
Label74 = "£10.58"

ElseIf cboTariff2.Text = "50002" Then
Label74 = "£11.51"

ElseIf cboTariff2.Text = "50005" Then
Label74 = "£11.85"

End If




Tom Ogilvy

how do i display a value in a user form as a result of a selectio.
 
Private Sub cboTariff2_click()
If cboTariff2 = 50006 Then
Label74 = "£10.58"

ElseIf cboTariff2.Text = "50002" Then
Label74 = "£11.51"

ElseIf cboTariff2.Text = "50005" Then
Label74 = "£11.85"

End If
End Sub

--
Regards,
Tom Ogilvy


"ptoddx1" wrote in message
...
I am trying to get a value to return in a label within a user form once an
option in a combobox is selected.

This is how I have tried it:

With cboTariff2

.AddItem "50006"
.AddItem "50002"
.AddItem "50005"

End With

If cboTariff2 = 50006 Then
Label74 = "£10.58"

ElseIf cboTariff2.Text = "50002" Then
Label74 = "£11.51"

ElseIf cboTariff2.Text = "50005" Then
Label74 = "£11.85"

End If




Tom Ogilvy

how do i display a value in a user form as a result of a selectio.
 
Noticed you left the quotes of the first check

The key point was, you can't set the values in the list and handle the
selection in the same routine. Load the list in the Userform_initialize()
event and use the click event to handle the selection.

Private Sub cboTariff2_click()
If cboTariff2 = "50006" Then
Label74 = "£10.58"

ElseIf cboTariff2.Text = "50002" Then
Label74 = "£11.51"

ElseIf cboTariff2.Text = "50005" Then
Label74 = "£11.85"

End If
End Sub

--
Regards,
Tom Ogilvy



"Tom Ogilvy" wrote in message
...
Private Sub cboTariff2_click()
If cboTariff2 = 50006 Then
Label74 = "£10.58"

ElseIf cboTariff2.Text = "50002" Then
Label74 = "£11.51"

ElseIf cboTariff2.Text = "50005" Then
Label74 = "£11.85"

End If
End Sub

--
Regards,
Tom Ogilvy


"ptoddx1" wrote in message
...
I am trying to get a value to return in a label within a user form once

an
option in a combobox is selected.

This is how I have tried it:

With cboTariff2

.AddItem "50006"
.AddItem "50002"
.AddItem "50005"

End With

If cboTariff2 = 50006 Then
Label74 = "£10.58"

ElseIf cboTariff2.Text = "50002" Then
Label74 = "£11.51"

ElseIf cboTariff2.Text = "50005" Then
Label74 = "£11.85"

End If







All times are GMT +1. The time now is 06:54 PM.

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