i made the search for "serrado" only gives me error "type mistach" on the code you told me to insert.Code:Sub insertsearch(sh As Worksheet, y As Long, x As String, tipo As String, refprod As String, prod As String, cod As String, acab As String, cor As String, lote As String, loc As String, forn As String) Dim fc As Range, lc As Long, op As Long, i As Long With sh 'with the worksheet whose name is equal to the value selected in the machine combobox in cell a5 'if the number of times that the value x (defined above based on cell filled in) 'is found in the column y (defined above) more than 0 times then If WorksheetFunction.CountIf(.Columns(y), x) > 0 Then Set fc = .Cells(2, y) 'set fc equal to cell in row 2, column y(defined above) Range("U7").Value = WorksheetFunction.CountIf(.Columns(y), x) 'loop through LC from one to the number of time x (defined above) appears in column y(defined above) For lc = 1 To WorksheetFunction.CountIf(.Columns(y), x) 'reset fc to the found cell in column y (defined above) whose value is equal to x (defined above) Set fc = .Columns(y).Find(what:=x, After:=fc(1, 5), _ LookIn:=xlValues, lookat:=xlPart, SearchOrder:=xlByRows, _ SearchDirection:=xlNext, MatchCase:=False).Offset(, -y + 1)
Rsilva




Reply With Quote