Vba excel copy rows with condition

Solved
lulu37 Posted messages 80 Status Membre -  
 Gpierron -
Hello,
I've been searching, but I can't find ...
I have 2 sheets in 1 workbook
I want to copy each row from sheet 1 that contains a value in column C to sheet 2
I thought about filters..., but I would prefer a code that allows for all rows to be considered even if I have active filters on the sheet
Configuration: excel97 vba6 under windows


Do you have the solution?

5 réponses

Armojax Posted messages 1862 Registration date   Status Membre Last intervention   1 529
 
Re, Ludivine,

A small macro...
Sub FiltreLulu() Dim Lig As Long Dim Col As String Dim NbrLig As Long Dim NumLig As Long Sheets("Feuil2").Activate ' destination sheet Col = "C" ' column of the non-empty data to test NumLig = 0 With Sheets("Feuil1") ' source sheet NbrLig = .Cells(65536, Col).End(xlUp).Row For Lig = 1 To NbrLig If .Cells(Lig, Col).Value <> "" Then .Cells(Lig, Col).EntireRow.Copy NumLig = NumLig + 1 Cells(NumLig, 1).Select ActiveSheet.Paste End If Next End With End Sub
25
lulu37 Posted messages 80 Status Membre 13
 
Hi there

It fails at the end of the procedure:
Cells(NumLig, 1).Select
error exe 1004
It apparently has nothing to do with my header rows, I tested without (just in case... I have 2 header rows on each sheet)
0
Gpierron
 
Thank you a thousand times!
0