hi friend i have this vba code just to serach 1 number my hope how to change this code to search more than number!!
Sub searchnumber()
Dim lc As Long, Num As Variant, r As Range, Col As Range, ct As Long
Num = InputBox("Enter the number to search for")
If Num = "" Then
Exit Sub
ElseIf IsNumeric(Num) Then
Num = Val(Num)
Else
MsgBox "You must enter a number"
Exit Sub
End If
Set r = Sheets("Sheet3").Range("A1").CurrentRegion
For Each Col In r.Columns
If WorksheetFunction.CountIf(Col, Num) > 0 Then
ct = ct + 1
If ct > 1 Then
Col.Copy Destination:=Sheets("Sheet5").Cells(1, Sheets("Sheet5").Cells(1, Columns.Count).End(xlToLeft).Column + 1)
Else
Col.Copy Destination:=Sheets("Sheet5").Cells(1, 1)
End If
End If
Next Col
End Sub
THANK YOU FOR HELP!!
Sub searchnumber()
Dim lc As Long, Num As Variant, r As Range, Col As Range, ct As Long
Num = InputBox("Enter the number to search for")
If Num = "" Then
Exit Sub
ElseIf IsNumeric(Num) Then
Num = Val(Num)
Else
MsgBox "You must enter a number"
Exit Sub
End If
Set r = Sheets("Sheet3").Range("A1").CurrentRegion
For Each Col In r.Columns
If WorksheetFunction.CountIf(Col, Num) > 0 Then
ct = ct + 1
If ct > 1 Then
Col.Copy Destination:=Sheets("Sheet5").Cells(1, Sheets("Sheet5").Cells(1, Columns.Count).End(xlToLeft).Column + 1)
Else
Col.Copy Destination:=Sheets("Sheet5").Cells(1, 1)
End If
End If
Next Col
End Sub
THANK YOU FOR HELP!!