Displays selection inside a readonly textbox

Pookiemeister

Active Member
Joined
Nov 26, 2015
Messages
306
Office Version
  1. 365
  2. 2010
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.
 

Some videos you may like

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,372
Office Version
  1. 365
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,109,072
Messages
5,526,628
Members
409,713
Latest member
roman9980

This Week's Hot Topics

Top