cut defined cells from a sheet paste them on another sheet then delete incompletes rows

Flavien

Board Regular
Joined
Jan 8, 2023
Messages
70
Office Version
  1. 365
Platform
  1. Windows
Hello Everybody!

My workbook contains 3 sheets.
Feuil1 (=sheet1) this Table is based on an extraction of our ERP.
Feuil2 (=sheet2) this second table is a minutoring table.
"Commandes" sheet allows me to drive the macro
=> ("Transfert de données") to cut/paste selected cells
=> ("Effacer lignes transférées") to delete incompletes rows.

To fill in the 2nd table I need to cut cells of the columns [A;B;C;E;F] from sheet1 and paste them in sheet2 in columns [A;B;C;D;G].
After cutting the cells, I would like to remove the incomplete rows from sheet1.

I can't make a macro that does the operation all at once. Also, the macro that deletes incomplete rows does not delete all rows at once. I have to click several times to clear all rows.

Does anyone have an idea ?

Thank you for your help.

EXAMPLE TRANSFERT & SUPPR LIGNES VIDES.xlsm
ABCDEFGHI
1N° PlanIndiceDésignationsous famillerédigé pardateétat N° de planLieu
20001AlunetteCCCFla18/01/2023En coursP8866-C
30002BlunetteCCCFla19/01/2023P8866-C
40003ClunetteCCCFla20/01/2023En coursP8866-C
50004AlunetteCCCFla21/01/2023P8866-C
60005BlunetteCCCFla22/01/2023En coursP8866-C
70006ClunetteCCCFla23/01/2023En coursP8866-C
80007AlunetteCCCFla24/01/2023En coursP8866-C
90008BlunetteCCCFla25/01/2023P8866-C
100009ClunetteCCCFla26/01/2023P8866-C
110010AlunetteCCCFla27/01/2023En coursP8866-C
120011BlunetteCCCFla28/01/2023En coursP8866-C
130012ClunetteCCCFla29/01/2023P8866-C
140013AlunetteCCCFla30/01/2023P8866-C
150014BlunetteCCCFla31/01/2023En coursP8866-C
160015ClunetteCCCFla01/02/2023P8866-C
170016AlunetteCCCFla02/02/2023En coursP8866-C
180017BlunetteCCCFla03/02/2023P8866-C
190018ClunetteCCCFla04/02/2023P8866-C
200019AlunetteCCCFla05/02/2023P8866-C
210020BlunetteCCCFla06/02/2023P8866-C
220021ClunetteCCCFla07/02/2023P8866-C
230022AlunetteCCCFla08/02/2023P8866-C
240023BlunetteCCCFla09/02/2023P8866-C
250024ClunetteCCCFla10/02/2023P8866-C
260025AlunetteCCCFla11/02/2023P8866-C
270026BlunetteCCCFla12/02/2023P8866-C
280027ClunetteCCCFla13/02/2023P8866-C
290028AlunetteCCCFla14/02/2023P8866-C
300029BlunetteCCCFla15/02/2023P8866-C
310030ClunetteCCCFla16/02/2023P8866-C
320031AlunetteCCCFla17/02/2023P8866-C
330032BlunetteCCCFla18/02/2023P8866-C
340033ClunetteCCCFla19/02/2023P8866-C
350034AlunetteCCCFla20/02/2023P8866-C
360035BlunetteCCCFla21/02/2023P8866-C
370036ClunetteCCCFla22/02/2023P8866-C
380037AlunetteCCCFla23/02/2023P8866-C
390038BlunetteCCCFla24/02/2023P8866-C
400039ClunetteCCCFla25/02/2023P8866-C
410040AlunetteCCCFla26/02/2023P8866-C
420041BlunetteCCCFla27/02/2023P8866-C
Feuil1


EXAMPLE TRANSFERT & SUPPR LIGNES VIDES.xlsm
ABCDEFGHI
1N° PlanIndiceDésignationPiloteDésignation de l'actionNos besoinsDate de lancementEtatLieu
20001BFla16/01/2023
30003BFla22/01/2023
40005BFla27/01/2023
50006BFla31/01/2023
60007BFla08/02/2023
70010BFla14/02/2023
80011BFla16/02/2023
90014BFla24/02/2023
100016BFla08/03/2023
110241BFla07/05/2023
120243BFla09/05/2023
130245BFla11/05/2023
140246BFla12/05/2023
150247BFla13/05/2023
160250BFla16/05/2023
170251BFla17/05/2023
180254BFla20/05/2023
190256BFla22/05/2023
200300BFla05/07/2023
Feuil2
 

Attachments

  • COMMANDES.JPG
    COMMANDES.JPG
    22.9 KB · Views: 16

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Below both macro

VBA Code:
[/
Sub transfert()

    Dim Lig As Long, I As Long
    Dim WS1 As Worksheet, WS2 As Worksheet
 
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
 
    Set WS1 = Worksheets("feuil1")
    Set WS2 = Worksheets("feuil2")
    Lig = 2
    For I = 2 To WS1.Range("A" & Rows.Count).End(xlUp).Row
        If WS1.Cells(I, 7) = "En cours" Then
        'If WS1.Cells(I, 8) = "En cours" And WS1.Cells(I, 8) = "texte2" Then
        
            WS1.Cells(I, "A").Cut WS2.Cells(Lig, "A")
            WS1.Cells(I, "B").Cut WS2.Cells(Lig, "B")
            WS1.Cells(I, "C").Cut WS2.Cells(Lig, "C")
            WS1.Cells(I, "E").Cut WS2.Cells(Lig, "D")
            WS1.Cells(I, "F").Cut WS2.Cells(Lig, "G")
            WS1.Cells(I, "C").Cut WS2.Cells(Lig, "C")

            Lig = Lig + 1
        End If
    Next I
 
 
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    
End Sub

Sub Supprime_lignes_vides()
Lig = 2

Sheets("feuil1").Select
Dim j As Long
For j = 2 To Sheets("feuil1").Range("A" & Rows.Count).End(xlUp).Row
  If Cells(j, 1) = "" Then Rows(j).Delete
Next j
    End Sub

]
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top