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

  • Thread starter Thread starter Alex
  • Start date Start date
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,
 
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top