How to Select Multiple Cells Conforming to A Certain Criteria Automatically?

A

Alex

Dear all,

I have a big table containing a lot of data in my worksheet. Within a
particular column, I want to select cells whose row numbers form an
arithmetic progression with a common difference 8(e.g. G6, G14,
G22, ...). At the moment, I can only perform this task by selecting
the cells individually while pressing "Ctrl", however, due to the
large number of data in the table, this work is very tedious.

Does anyone know if there is an automatic way to select these cells?

Thank you.

Best wishes,
 
J

jan

Alex,

This code can do the job for you.

Sub SelectCells()
Dim rng1 As Range
Dim i As Long
Set rng1 = Range("G6")
For i = 1 To 500
Set rng1 = Union(rng1, Range("G" & 6 + i * 8))
Next
If Not rng1 Is Nothing Then
rng1.Select
End If
End Sub

Jan
 
R

Ragdyer

What are you looking to accomplish *after* you make your cell selections?

Formulas can be configured to perform various functions on cells, where you
might enter the progression of choice in another cell.
 
Top