So I have a label that will depend on the value of ComboBox. If the Value of ComboBox contains a specific string then it'll execute a Match Index from the range that I specified.
I managed to do what I wanted but the problem now is I want to clear the label if the ComboBox does not contain the string that I'm looking for. I tried to add an 'ElseIf' then put the caption to blank but after doing so, if I changed that value of ComboBox it will stay as blank.
Public Sub SetBonus() Dim mySet As Range, twoParts As Range, fourParts As Range, sevenParts As Range, cnt As Range Set mySet = ThisWorkbook.Names("setBns").RefersToRange Set twoParts = ThisWorkbook.Names("twoParts").RefersToRange Set fourParts = ThisWorkbook.Names("fourParts").RefersToRange Set sevenParts = ThisWorkbook.Names("sevenParts").RefersToRange For Each cnt In mySet If InStr(cbxItem.Value, cnt) <> 0 Then With WorksheetFunction Label1.Caption = .Index(twoParts, .Match(cnt, mySet, 0)) Label2.Caption = .Index(fourParts, .Match(cnt, mySet, 0)) Label3.Caption = .Index(sevenParts, .Match(cnt, mySet, 0)) End With End If Next cnt End Sub
Thanks in advance,