ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Select each alternate row in a worksheet (https://www.excelbanter.com/excel-discussion-misc-queries/198068-select-each-alternate-row-worksheet.html)

Abdul Shakeel

Select each alternate row in a worksheet
 
Hi all,

Could I select each alternate row in my seleceted range of a worksheet,
there is any way to do this.

Gary''s Student

Select each alternate row in a worksheet
 
Try this macro:

Sub everyothre()
Set s = Selection
r1 = s.Cells(1, 1).Row
r2 = s.Rows.Count + r1 - 1
Set cmp = s.Cells(1, 1).EntireRow
For i = r1 To r2 Step 2
Set parts = Cells(i, 1).EntireRow
Set cmp = Union(cmp, parts)
Next
Set cmp = Intersect(cmp, s)
cmp.Select
End Sub

--
Gary''s Student - gsnu200798


"Abdul Shakeel" wrote:

Hi all,

Could I select each alternate row in my seleceted range of a worksheet,
there is any way to do this.



All times are GMT +1. The time now is 08:15 AM.

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