Hi obed_cruz
Welcome to ExcelFox
Use this in the userform
Code:
Private Sub MOSTAR_MES_Click()
Dim rngCell As Range
Dim rngUnion As Range
Dim lngListLoop As Long
Dim strMostar As String
For lngListLoop = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(lngListLoop) Then
strMostar = strMostar & "|" & ListBox1.List(lngListLoop)
End If
Next lngListLoop
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
'''''''''''''''''''''''''''''''''''''''''''''
For Each rngCell In Range("D10:SP10")
If InStr(1, strMostar, "|" & Trim(rngCell.Value)) Then
If Not rngUnion Is Nothing Then
Set rngUnion = Application.Union(rngUnion, rngCell)
Else
Set rngUnion = rngCell
End If
End If
Next rngCell
If Not rngUnion Is Nothing Then
Range("D10:SP10").EntireColumn.Hidden = True
rngUnion.EntireColumn.Hidden = False
End If
''''''''''''''''''''''''''''''''''''''''''''''''''
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
''''''''''''''''''''''''''''''''''''''''''''''''''
End Sub
Bookmarks