ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I select all odd-numbered rows in huge excel sheet? (https://www.excelbanter.com/excel-discussion-misc-queries/124860-how-do-i-select-all-odd-numbered-rows-huge-excel-sheet.html)

bgilliam

How do I select all odd-numbered rows in huge excel sheet?
 
Want to select all odd-numbered rows in a spreadsheet without going thru the
task of hand selecting each.

Gary''s Student

How do I select all odd-numbered rows in huge excel sheet?
 
Enter and run this small macro:

Sub odds()
Dim r As Range
Set rr = Cells(1, "A")
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
For i = 1 To nLastRow Step 2
Set rr = Union(rr, Cells(i, "A"))
Next
rr.EntireRow.Select
End Sub


If you are unfamiliar with VBA, See:

http://www.mvps.org/dmcritchie/excel/getstarted.htm
--
Gary''s Student


"bgilliam" wrote:

Want to select all odd-numbered rows in a spreadsheet without going thru the
task of hand selecting each.



All times are GMT +1. The time now is 04:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com