View Single Post
 
Old 04-14-2019, 06:30 PM
jrooney7 jrooney7 is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Sep 2018
Posts: 23
jrooney7 is on a distinguished road
Default

That was perfect! I added an AfterUpdate event to that combobox to pull the corresponding item description. In case anyone needs it:

Code:
Private Sub UserForm_Initialize()

    Dim oTable As Table
    Dim i As Long, m As Long
    Dim oData As Range
        Set oTable = ActiveDocument.Tables(1)
        i = oTable.Rows.Count
        For m = 1 To i
            Set oData = oTable.Cell(m, 2).Range
            oData.End = oData.End - 1
            If oData.Text <> "" Then ItemComboBox.AddItem oData.Text
        Next m
        ItemComboBox.AddItem "[Select Item]", 0
        ItemComboBox.ListIndex = 0
    
End Sub

Private Sub ItemComboBox_AfterUpdate()

    Dim oTable As Table
    Dim i As Long, m As Long
    Dim oData As Range
    Dim sLastChar As String
    Dim sCellText As String
        Set oTable = ActiveDocument.Tables(1)
        i = oTable.Rows.Count
        For m = 1 To i
        Set oData = oTable.Cell(m, 2).Range
            oData.End = oData.End - 1
        sCellText = oTable.Cell(m, 4).Range.Text
        sLastChar = Right(sCellText, 1)
            If ItemComboBox.Text = oData.Text Then
                If sLastChar = Chr(7) Or sLastChar = Chr(13) Then
                    sCellText = Left(sCellText, Len(sCellText) - 2)
                    sLastChar = Right(sCellText, 1)
                End If
                ItemDescriptionTextBox.Value = sCellText
            End If
        Next m

End Sub
Thank you for your help!
Reply With Quote