/ / Excel / Sposta automaticamente la riga completa su un altro foglio: excel, excel-vba, vba

Excel / Sposta automaticamente la riga completa su un altro foglio: excel, excel-vba, vba

Ho bisogno di modificare un foglio di calcolo Excel in modo che una rigapassa automaticamente da un foglio ("Open_Followups") a un altro foglio ("Closed_Followups") se contiene "Sì" nella colonna "I" ("Evento completato / chiuso").

Non ho esperienza in VBA e mi chiedevo se qualcuno qui potrebbe aiutarmi a creare il codice?

Screenshot delle prime colonne sul foglio.

immagine dello schermo

Non sono sicuro se è importante, ma sto usando Excel 2016 su un computer Mac

risposte:

0 per risposta № 1

Ho scritto un piccolo script per te (in MS Excel)che cerca una "y" nella riga B e se trova una corrispondenza copia il valore dalla riga A al Foglio "Tabelle2". Questo è solo un esempio (non sono qui per fare il tuo lavoro per te;)) Gioca con esso e importalo nella tua cartella di lavoro e regolalo dove necessario.

Private Sub CommandButton1_Click()

Dim LastRow As Long
Dim LastRow2 As Long
Dim counter As Integer

"get the last row in this sheet (column A)
With ActiveSheet
LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
End With

"get the last row in the sheet "Tabelle2" (column A)
With Sheets("Tabelle2")
LastRow2 = .Cells(.Rows.Count, 1).End(xlUp).Row
End With

"the counter is needed to add dynamically to "Tabelle2"
counter = LastRow2 + 1
"run from 1 to the last row in your first sheet
For i = 1 To LastRow
"search for matches
If Cells(i, 2).Text = "y" Then
"if found, write to "Tabelle2"
Sheets("Tabelle2").Cells(counter, 1).Value = Cells(i, 2).Offset(0, -1).Value
counter = counter + 1
End If
Next

End Sub