Hello ashishkhurana93,
Link ComboBox1 to a Cell. I have chosen Cell D11.
Then change your Code for ComboBox1 as shown below;
Option Explicit
Private Sub ComboBox1_Change()
Dim r As Range, rList As Range, rListBoxStore As Range, rAll As Range
Dim iRow As Integer, iCol As Integer
Dim sTerm As String
Sheets("Workings").Range("A1:A20").Clear
iRow = 1
iCol = 1
sTerm = ComboBox1.Value
With Sheets("Sheet1")
Set rAll = .Range(.Cells(2, 2), .Cells(2, 2).End(xlDown))
For Each r In rAll
If InStr(r, sTerm) Then
With Sheets("Workings")
.Cells(iRow, iCol) = r.Offset(0, -1)
iRow = iRow + 1
Set rList = Sheets("Workings").Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))
rList.Name = "ListBoxRowSource1"
End With
End If
Next
End With
With Sheets("Sheet1").ListBox2
.ListFillRange = ""
.ListFillRange = "ListBoxRowSource1"
End With
Sheet1.Range("M3:M" & Range("L" & Rows.Count).End(xlUp).Row).Formula = ("=IF($D$11=""Region"",TRUE,FALSE)")
Sheet1.Range("M3:M" & Range("L" & Rows.Count).End(xlUp).Row) = Sheet1.Range("M3:M" & Range("L" & Rows.Count).End(xlUp).Row).Value
Sheet1.Range("P3:P" & Range("O" & Rows.Count).End(xlUp).Row).Formula = ("=IF($D$11=""Country"",TRUE,FALSE)")
Sheet1.Range("P3:P" & Range("O" & Rows.Count).End(xlUp).Row) = Sheet1.Range("P3:P" & Range("O" & Rows.Count).End(xlUp).Row).Value
End Sub
Regards
Bookmarks