ola pessoal
So me falta por isto a funcionar
o codigo apenas pesquisa por "acabamento" os restantes da ero "Type mismatch"
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, 1) '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)
'when a value is found provide a message box listing the record found to make sure it is the correct record
If UCase(fc(1, 1)) Like UCase(tipo) And UCase(fc(1, 2)) Like UCase(refprod) And UCase(fc(1, 3)) Like UCase(prod) And UCase(fc(1, 4)) Like UCase(cod) And UCase(fc(1, 5)) Like UCase(acab) And UCase(fc(1, 6)) Like UCase(cor) And UCase(fc(1, 7)) Like UCase(lote) And UCase(fc(1, 8)) Like UCase(loc) And UCase(fc(1, 9)) Like UCase(forn) Then
Cells(linhas, 1).Value = sh.Name
For i = 1 To 18 'loop through the variable i from numbers 1 To 18 (represents column numbers)
'distribute the found information accordingly to row 2 of the Stock worksheet
Cells(linhas, i + 1) = .Cells(fc.Row, i)
Next i 'move to next i in the i loop
linhas = linhas + 1
End If
Next lc 'move to next lc in the loop
Range("U5").Value = linhas
ElseIf x = "nada" Then
MsgBox "Preencha no minimo um campo para iniciar a pesquisa.", vbOKOnly, "Nada" 'if no value is found the msgbox part not available
End If
End With
End Sub
agradeço a ajuda um abraço
rsilva
Postado : 28/11/2012 10:56 am