da air.wolf » gio set 18, 2003 2:49 pm
Copiati il seguente ciclo nelle macro. Controlla che i fogli si chiamino realmente foglio1 e foglio2, i dati da inserire siano nel foglio2. La macro ce c'è qui ti riempie le colonne fino ad H.
Ti esce anche un menù quando la lanci (passo passo, vai veloce, ferma)
Sub trova()
riga = ActiveCell.Row
NONCHIEDERE = False
While ActiveSheet.Range("A" & Format(riga)).Value <> ""
rig = 2
mm = ActiveSheet.Range("A" & Format(riga)).Value
trovato = False
Do While Worksheets("foglio1").Range("A" & Format(rig)).Value <> ""
If Format(Worksheets("foglio1").Range("A" & Format(rig)).Value) = Format(ActiveSheet.Range("A" & Format(riga)).Value) Then
mm = Worksheets("foglio1").Range("A" & Format(rig)).Value
ActiveSheet.Range("B" & Format(riga)).Value = Worksheets("foglio1").Range("B" & Format(rig)).Value
ActiveSheet.Range("C" & Format(riga)).Value = Worksheets("foglio1").Range("C" & Format(rig)).Value
ActiveSheet.Range("D" & Format(riga)).Value = Worksheets("foglio1").Range("D" & Format(rig)).Value
ActiveSheet.Range("E" & Format(riga)).Value = Worksheets("foglio1").Range("E" & Format(rig)).Value
ActiveSheet.Range("F" & Format(riga)).Value = Worksheets("foglio1").Range("F" & Format(rig)).Value
ActiveSheet.Range("G" & Format(riga)).Value = Worksheets("foglio1").Range("G" & Format(rig)).Value
ActiveSheet.Range("H" & Format(riga)).Value = Worksheets("foglio1").Range("H" & Format(rig)).Value
trovato = True
Exit Do
End If
rig = rig + 1
Loop
If Not trovato Then
MsgBox "Codice non trovato : " & ActiveSheet.Range("A" & Format(riga)).Value, vbCritical + vbOKOnly, "ATTENZIONE"
Else
If Not NONCHIEDERE Then
RISP = MsgBox("Continuare passo passo (SI) - Uscire (NO) - Vai veloce (CANCEL)", vbQuestion + vbYesNoCancel, "Lancio")
If RISP = 7 Then Exit Sub
If RISP = 2 Then NONCHIEDERE = True
End If
End If
riga = riga + 1
Wend
End Sub