Displays selection inside a readonly textbox

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
563
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Code:
Private Sub cmbPrdCde_Enter()
    Dim ary As Variant, nary As Variant, r As Long
    If cmbSDPFLine.Value = "Slat" Then
        cmbPrdCde.Clear
        cmbPrdCde.Value = ""
        With ThisWorkbook.Worksheets(cmbSDPFLine.Value)
            ary = .Range("B3", .Range("B" & Rows.Count).End(xlUp).Offset(, 1))
            ReDim nary(1 To UBound(ary))
                For r = 1 To UBound(ary)
                    nary(r) = ary(r, 1) & " (" & ary(r, 2) & ")"
                Next r
        Me.cmbPrdCde.List = nary
        End With
    End If
    End Sub
The above code places the values, from a worksheet called "Slat", of Column B and C and concatenates them into one combo box on a user form. Column B contains the product code for the item and column C contains the name of the item. How do I, depending on what is selected, display the value of just column C inside a read only text box.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
If you mean a locked textbox try
Code:
Private Sub cmbPrdCde_Click()
   Dim v As String
   v = Split(Me.cmbPrdCde.Value, " (")(1)
   Me.TextBox1.Value = Left(v, Len(v) - 1)
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,272
Members
449,075
Latest member
staticfluids

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