PDA

View Full Version : why blanco lines after a copy ?



verlof
10-23-2016, 09:47 AM
Hello

Attached 4 Excell sheets.

Data from the Excell sheets test17, testdb98b and testdb57b is collect into 1 sheet (= zsamen 17 )
These 3 sheets are in another directory as the Excell sheet zsamen 17.

The VBA coding in the Excell sheet zsamen17 collects rows from the 3 other Excell sheets
In the 3 Excell sheets starting with the word 'test' is always a workbook with the name transfer.
In a workbook transfer, the data to be copied starts always in the cell C5.
The number of rows can be 1 row or 100 rows or ... and is different in each sheet.

The different rows are collected into the sheet zsamen17.

But sometimes, blanco lines are copied into the sheet zsamen17.

Can somebody explain me why this is happening ?

SamT
10-23-2016, 11:08 AM
Because you are copying the UsedRange, which might include blank lines or even formulas with blank results.

Better:
Wb.ActiveSheet.Range("a1").CurrentRegion.Copy
ThisWorkbook.Sheets("bestellingen").Cells(Rows.Count, "C").End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues

NoSparks
10-23-2016, 11:17 AM
Have you tried commenting out
On Error Resume Next to see if Excel is wanting to notify you of anything ?

Sorry, think I misinterpreted "These 3 sheets are in another directory as the Excell sheet zsamen 17."