Solved

I need to select only 500 rows covering any range of data (sampling)

Posted on 2014-09-03
5
123 Views
Last Modified: 2014-09-04
Dear All,

I need to select only 500 rows covering any range of the input sheet  (sampling) as attached here. The rows should be selected equally to cover the data range.

I need the first row and the last row and the rows between should be equally selected and moved the output sheet.

Regards,

Dallag
Convert-Large-files-to-500-GA.xlsx
0
Comment
Question by:dallagmm
5 Comments
 
LVL 19

Expert Comment

by:helpfinder
ID: 40302746
It is definitely possible to use some VBA macro to achieve this, but if you need only this I guess the fastest way will be manual work instead of looking for code and make .xlsb
Just press F5 in your Input sheet and type A1:B500 to select first 500 rows and copy-paste it into Output sheet.
0
 

Author Comment

by:dallagmm
ID: 40302768
I need to select 500 rows to cover the range. For example if I have 1000 rows then I should read the first row and skip the second and read the third and skip the fourth. So at the end I will be able to get 500 rows starting from the first row to the last row.

Regards,

Dallag
0
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40302839
Hi,

pls try

Sub Macro1()
'
' Macro1 Macro

LinesToBeSelected = 500
cnt = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp)).Count
diff = cnt / LinesToBeSelected
Range("A1").EntireRow.Select
For Idx = 1 + diff To (LinesToBeSelected - 1) * diff Step diff
    rw = Int(Idx)
    Union(Selection, Range(rw & ":" & rw)).Select
Next
Selection.Copy Destination:=Sheets("Output").Range("A1")
Range("A1").Select
End Sub

Open in new window

Regards
0
 
LVL 12

Expert Comment

by:James Elliott
ID: 40302849
What do you want to happen if you have 1353 rows, such as in your data?
0
 

Author Closing Comment

by:dallagmm
ID: 40303227
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now