Inserisci In K2 il valore 10 (K1 testata = "N. da Trovare")
e sostituisci la macro precedente con questa
- Codice: Seleziona tutto
Sub trovaVal()
Range("G8:P8").ClearContents
UE = Worksheets("Foglio2").Range("A" & Rows.Count).End(xlUp).Row
Area = Worksheets("Foglio2").Range("A2:AX" & UE)
valore = Range("F8").Value
If [I2] > 50 Or [I2] = 0 Then
MsgBox "Digitare N. Colonne (da 1 a 50)"
Range("I2").Select
GoTo Fine
End If
If [J2] = "" Then
MsgBox "digitare inizio riga"
Range("J2").Select
GoTo Fine
End If
If [K2] = "" Then
MsgBox "digitare Numeri da trovare"
Range("K2").Select
GoTo Fine
End If
Inizio = [J2]
For RR = Inizio To UE
For CC = 1 To [I2]
If Worksheets("Foglio2").Cells(RR, CC).Value = valore Then
Cells(8, TR + 7).Value = Worksheets("Foglio2").Cells(RR - 1, CC).Value
TR = TR + 1
If TR = Range("K2").Value Then GoTo esci
End If
Next CC
Next RR
esci:
Fine:
End Sub
Fai attenzione, io ho ancora il foglio dove i dati venivano riportati nella riga 8 da G verso destra e utilizzavo le prime due righe come configurazione, sta a te ora adattare le varie celle, spostando gli indirizzi secondo la tua esigenza.
Ciao