Selecting every fourth cell in a coloumn

  • Thread starter Thread starter hke
  • Start date Start date
H

hke

Hi all. I would like som help on the following:

Like when using the ctrl key, I want to select several non-adjacent
cells. I want to select every fourth cell in a coloumn with about 1500
cells.

The code below helps me to move the selection down, but it does not
keep the previous selection. Any sugestions?

ActiveCell.Select
For i = 1 To 1500
ActiveCell.Offset(3).Select
i = i + 1
Next
 
You can adapt this to suit your needs.

Sub EveryFourth()
Dim i As Integer
Dim rngR As Range

For i = 1 To 1500
If Not rngR Is Nothing Then
Set rngR = Union(rngR, Cells(i * 4, 1))
Else
Set rngR = Cells(i * 4, 1)
End If
Next i

rngR.Select

End Sub

Tested using Excel 97SR2 on Windows 98SE,

HTH
Paul
 
hke said:
Hi all. I would like som help on the following:

Like when using the ctrl key, I want to select several non-adjacent
cells. I want to select every fourth cell in a coloumn with about 1500
cells.

The code below helps me to move the selection down, but it does not
keep the previous selection. Any sugestions?

ActiveCell.Select
For i = 1 To 1500
ActiveCell.Offset(3).Select
i = i + 1
Next

Try this:

Dim MyRange as Range
Set MyRange=ActiveCell

For i = 1 to 500
ActiveCell.Offset(3).Select
Set MyRange = Union (MyRange, ActiveCell)
Next i

Geoff
 
Back
Top