Bonjour à tous
Bonjour FFO
Tu aurais pu faire une boucle pour la copie, vu que les colonnes se suivent
Private Sub cmdSearch_Click()
Dim RowNum As Long
Dim SearchRow As Long
Dim lettrecolonne As String
Dim numcolonne As Long
Dim i As Long
Dim Ws As Worksheet, Wd As Worksheet
Set Ws = Sheets("Raw Material")
Set Wd = Sheets("Product search")
RowNum = 2
SearchRow = 2
If txtKeywords <> "" Then
lettrecolonne = InputBox("Veuillez saisir la lettre de la colonne de recherche !!!", "Lettre Colonne")
End If
If lettrecolonne <> "" And txtKeywords <> "" Then
numcolonne = Range(lettrecolonne & "1").Column
If Wd.Range("A2") <> "" Then
Wd.Range("A2", "Z" & Wd.Range("A65536").End(xlUp).Row).Clear
End If
Ws.Activate
Do Until Cells(RowNum, 1).Value = ""
'If InStr(1, Cells(RowNum, 2).Value, txtKeywords.Value, vbTextCompare) > 0 Then
If Cells(RowNum, lettrecolonne) Like txtKeywords & "*" Then
For i = 1 To 26
Wd.Cells(SearchRow, i).Value = Ws.Cells(RowNum, i).Value
Next i
' Worksheets("Product Search").Cells(SearchRow, 1).Value = Cells(RowNum, 1).Value
' Worksheets("Product Search").Cells(SearchRow, 2).Value = Cells(RowNum, 2).Value
' Worksheets("Product Search").Cells(SearchRow, 3).Value = Cells(RowNum, 3).Value
' Worksheets("Product Search").Cells(SearchRow, 4).Value = Cells(RowNum, 4).Value
' Worksheets("Product Search").Cells(SearchRow, 5).Value = Cells(RowNum, 5).Value
' Worksheets("Product Search").Cells(SearchRow, 6).Value = Cells(RowNum, 6).Value
' Worksheets("Product Search").Cells(SearchRow, 7).Value = Cells(RowNum, 7).Value
' Worksheets("Product Search").Cells(SearchRow, 8).Value = Cells(RowNum, 8).Value
' Worksheets("Product Search").Cells(SearchRow, 9).Value = Cells(RowNum, 9).Value
' Worksheets("Product Search").Cells(SearchRow, 10).Value = Cells(RowNum, 10).Value
' Worksheets("Product Search").Cells(SearchRow, 11).Value = Cells(RowNum, 11).Value
' Worksheets("Product Search").Cells(SearchRow, 12).Value = Cells(RowNum, 12).Value
' Worksheets("Product Search").Cells(SearchRow, 13).Value = Cells(RowNum, 13).Value
' Worksheets("Product Search").Cells(SearchRow, 14).Value = Cells(RowNum, 14).Value
' Worksheets("Product Search").Cells(SearchRow, 15).Value = Cells(RowNum, 15).Value
' Worksheets("Product Search").Cells(SearchRow, 16).Value = Cells(RowNum, 16).Value
' Worksheets("Product Search").Cells(SearchRow, 17).Value = Cells(RowNum, 17).Value
' Worksheets("Product Search").Cells(SearchRow, 18).Value = Cells(RowNum, 18).Value
' Worksheets("Product Search").Cells(SearchRow, 19).Value = Cells(RowNum, 19).Value
' Worksheets("Product Search").Cells(SearchRow, 20).Value = Cells(RowNum, 20).Value
' Worksheets("Product Search").Cells(SearchRow, 21).Value = Cells(RowNum, 21).Value
' Worksheets("Product Search").Cells(SearchRow, 22).Value = Cells(RowNum, 22).Value
' Worksheets("Product Search").Cells(SearchRow, 23).Value = Cells(RowNum, 23).Value
' Worksheets("Product Search").Cells(SearchRow, 24).Value = Cells(RowNum, 24).Value
' Worksheets("Product Search").Cells(SearchRow, 25).Value = Cells(RowNum, 25).Value
' Worksheets("Product Search").Cells(SearchRow, 26).Value = Cells(RowNum, 26).Value
SearchRow = SearchRow + 1
End If
RowNum = RowNum + 1
Loop
If SearchRow = 2 Then
MsgBox "No products were found that match your search criteria"
Exit Sub
End If
Else
txtKeywords = ""
End If
'lstSearchResults.RowSource = "SearchResults"
Call Userform_Initialize
End Sub