Remove some intermediate lines
Hi,
I wouldn't 'remove' the lines I'd copy the edited data elsewhere like this.
Change SrcSheet to the sheet containing data
DestSheet to where the data is to go
MyStep to the required step
Sub Mariner()
Dim DstSheet As String
Dim SrcSheet As String
Dim LastRow As Long, MyStep As Long
Dim CopyRange As Range
SrcSheet = "Sheet3" 'Change to suit
DstSheet = "Sheet2" 'change to suit
MyStep = 2 'Change to suit
LastRow = Sheets(SrcSheet).Cells(Cells.Rows.Count, "A").End(xlUp).Row
For x = 1 To LastRow Step MyStep
If CopyRange Is Nothing Then
Set CopyRange = Sheets(SrcSheet).Rows(x).EntireRow
Else
Set CopyRange = Union(CopyRange, Sheets(SrcSheet).Rows(x).EntireRow)
End If
Next
CopyRange.Copy
Sheets(DstSheet).Range("a2").PasteSpecial
End Sub
Mike
"Luciano Paulino da Silva" wrote:
Dear all,
I have worksheets with columns containg more than 50000 numbers. Do
you have any idea about a macro in order to remove some intermediate
lines (1, 2, 3, 4, 5, 6, 7, 8,...) of an Excel Worksheet keeping the
values between them like the following:
Data
999.771 4
999.792 5
999.812 5
999.833 5
999.853 5
999.873 5
999.894 5
999.914 5
999.935 4
999.955 3
999.976 3
999.996 3
1000.016 3
Result removing 1 line:
999.771 4
999.812 5
999.853 5
999.894 5
999.935 4
999.976 3
1000.016 3
Result removing 2 lines:
999.771 4
999.833 5
999.894 5
999.955 3
1000.016 3
Result removing 3 lines:
999.771 4
999.833 5
999.914 5
999.996 3
Result removing 4 lines:
999.771 4
999.873 5
999.976 3
Thanks in advance,
Luciano
.
|