Solved

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

Posted on 2014-09-03
5
122 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
Comment Utility
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
Comment Utility
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 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
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
Comment Utility
What do you want to happen if you have 1353 rows, such as in your data?
0
 

Author Closing Comment

by:dallagmm
Comment Utility
Thanks
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

762 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

10 Experts available now in Live!

Get 1:1 Help Now