Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Remove some intermediate lines

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default Remove some intermediate lines

Do you mean you want to sample every n-th number in order to reduce your
dataset size ?

Tim

"Luciano Paulino da Silva" wrote in message
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Remove some intermediate lines

On 20 nov, 15:17, Mike H wrote:
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
.


Dear Mike,
Thank you for your response. The macro is working properly. However,
it is very slow to shetts containing more than 50000 lines. After 20
min the excel sttoped working and I'm using an workstation with two
XEON processors.
Have you any idea about what could we do?
Luciano
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Remove some intermediate lines

On 20 nov, 15:41, "Tim Williams" wrote:
Do you mean you want to sample every n-th number in order to reduce your
dataset size ?

Tim

"Luciano Paulino da Silva" wrote in ...

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


Yes, exactly.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Remove some intermediate lines

Give this code a try, just set the 3 Const (constant) statements to match
your actual sheet layout)...

Sub ThinTheData()
Dim X As Long, LastRow As Long
Const NumberOfRowsToRemove As Long = 3
Const SheetName As String = "Sheet1"
Const DataColumn As Long = 1
With Worksheets(SheetName)
LastRow = .Cells(.Rows.Count, DataColumn).End(xlUp).Row
For X = 1 + LastRow - (LastRow Mod (NumberOfRowsToRemove + 1)) _
To 1 Step -(NumberOfRowsToRemove + 1)
.Cells(X + 1, "A").Resize(NumberOfRowsToRemove).EntireRow.De lete
Next
End With
End Sub

Note: This code assumes your data start on Row 1.

--
Rick (MVP - Excel)


"Luciano Paulino da Silva" wrote in message
...
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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Remove some intermediate lines

And here is the version that allows your data to start on a different row
than Row 1...

Sub ThinTheData()
Dim X As Long, LastRow As Long
Const NumberOfRowsToRemove As Long = 4
Const SheetName As String = "Sheet5"
Const DataStartRow As Long = 4
Const DataColumn As Long = 1
With Worksheets(SheetName)
LastRow = .Cells(.Rows.Count, DataColumn).End(xlUp).Row
For X = DataStartRow + LastRow - (LastRow Mod (NumberOfRowsToRemove _
+ 1)) To 1 Step -(NumberOfRowsToRemove + 1)
.Cells(X + 1, "A").Resize(NumberOfRowsToRemove).EntireRow.De lete
Next
End With
End Sub

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Give this code a try, just set the 3 Const (constant) statements to match
your actual sheet layout)...

Sub ThinTheData()
Dim X As Long, LastRow As Long
Const NumberOfRowsToRemove As Long = 3
Const SheetName As String = "Sheet1"
Const DataColumn As Long = 1
With Worksheets(SheetName)
LastRow = .Cells(.Rows.Count, DataColumn).End(xlUp).Row
For X = 1 + LastRow - (LastRow Mod (NumberOfRowsToRemove + 1)) _
To 1 Step -(NumberOfRowsToRemove + 1)
.Cells(X + 1, "A").Resize(NumberOfRowsToRemove).EntireRow.De lete
Next
End With
End Sub

Note: This code assumes your data start on Row 1.

--
Rick (MVP - Excel)


"Luciano Paulino da Silva" wrote in
message
...
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



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Remove some intermediate lines

On 20 nov, 17:43, "Rick Rothstein"
wrote:
And here is the version that allows your data to start on a different row
than Row 1...

Sub ThinTheData()
* Dim X As Long, LastRow As Long
* Const NumberOfRowsToRemove As Long = 4
* Const SheetName As String = "Sheet5"
* Const DataStartRow As Long = 4
* Const DataColumn As Long = 1
* With Worksheets(SheetName)
* * LastRow = .Cells(.Rows.Count, DataColumn).End(xlUp).Row
* * For X = DataStartRow + LastRow - (LastRow Mod (NumberOfRowsToRemove _
* * * * * * * * * * * * * * + 1)) To 1 Step -(NumberOfRowsToRemove + 1)
* * * .Cells(X + 1, "A").Resize(NumberOfRowsToRemove).EntireRow.De lete
* * Next
* End With
End Sub

--
Rick (MVP - Excel)

"Rick Rothstein" wrote in message

...

Give this code a try, just set the 3 Const (constant) statements to match
your actual sheet layout)...


Sub ThinTheData()
*Dim X As Long, LastRow As Long
*Const NumberOfRowsToRemove As Long = 3
*Const SheetName As String = "Sheet1"
*Const DataColumn As Long = 1
*With Worksheets(SheetName)
* *LastRow = .Cells(.Rows.Count, DataColumn).End(xlUp).Row
* *For X = 1 + LastRow - (LastRow Mod (NumberOfRowsToRemove + 1)) _
* * * * * * * * * * * * * * To 1 Step -(NumberOfRowsToRemove + 1)
* * *.Cells(X + 1, "A").Resize(NumberOfRowsToRemove).EntireRow.De lete
* *Next
*End With
End Sub


Note: This code assumes your data start on Row 1.


--
Rick (MVP - Excel)


"Luciano Paulino da Silva" wrote in
message
...
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


Thank you Rick!
The code is perfect for us.
Luciano
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Remove some intermediate lines

On 20 nov, 17:43, "Rick Rothstein"
wrote:
And here is the version that allows your data to start on a different row
than Row 1...

Sub ThinTheData()
* Dim X As Long, LastRow As Long
* Const NumberOfRowsToRemove As Long = 4
* Const SheetName As String = "Sheet5"
* Const DataStartRow As Long = 4
* Const DataColumn As Long = 1
* With Worksheets(SheetName)
* * LastRow = .Cells(.Rows.Count, DataColumn).End(xlUp).Row
* * For X = DataStartRow + LastRow - (LastRow Mod (NumberOfRowsToRemove _
* * * * * * * * * * * * * * + 1)) To 1 Step -(NumberOfRowsToRemove + 1)
* * * .Cells(X + 1, "A").Resize(NumberOfRowsToRemove).EntireRow.De lete
* * Next
* End With
End Sub

--
Rick (MVP - Excel)

"Rick Rothstein" wrote in message

...

Give this code a try, just set the 3 Const (constant) statements to match
your actual sheet layout)...


Sub ThinTheData()
*Dim X As Long, LastRow As Long
*Const NumberOfRowsToRemove As Long = 3
*Const SheetName As String = "Sheet1"
*Const DataColumn As Long = 1
*With Worksheets(SheetName)
* *LastRow = .Cells(.Rows.Count, DataColumn).End(xlUp).Row
* *For X = 1 + LastRow - (LastRow Mod (NumberOfRowsToRemove + 1)) _
* * * * * * * * * * * * * * To 1 Step -(NumberOfRowsToRemove + 1)
* * *.Cells(X + 1, "A").Resize(NumberOfRowsToRemove).EntireRow.De lete
* *Next
*End With
End Sub


Note: This code assumes your data start on Row 1.


--
Rick (MVP - Excel)


"Luciano Paulino da Silva" wrote in
message
...
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


Thank you Rick!
The code is perfect for us.
Luciano
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOW DO I REMOVE/DELETE LINES IN EXCEL? George Brassington Excel Discussion (Misc queries) 2 July 29th 09 04:35 AM
REMOVE CERTAIN LINES IN A PIVIOT TABLE Browny Excel Discussion (Misc queries) 0 July 24th 08 04:57 AM
remove print area lines Mike Excel Discussion (Misc queries) 1 March 8th 06 09:01 PM
Remove Blank Lines Nigel Excel Programming 1 November 28th 05 02:58 PM
Remove lines from Group Box Lori Burton Charts and Charting in Excel 1 July 25th 05 06:50 PM


All times are GMT +1. The time now is 12:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"