Solved

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

Posted on 2014-09-03
5
126 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:Mohammed Dallag
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:Mohammed Dallag
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 50

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:Mohammed Dallag
ID: 40303227
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

733 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