15,907,395 members
1.00/5 (1 vote)
See more: (untagged)
I dont use visual basic but i need to select every 4th coloumn of my worksheet .. I need it for some application ... can any one tell me how to do it in visual basic ..
Posted
Updated 2-Oct-20 0:28am
Dalek Dave 17-Jun-10 10:35am
5 rows by 2000 columns is completely the wrong approach to using spreadsheets.

Please think about having 2000 rows of 5 columns, it is more sensible that way.

## Solution 1

It is actually very easy, and I will give you the code.
However, before I do I just need to know if the columns are fixed, ie you want columns D, H, L, etc?

If so, something like this...

`Range("F:F,H:H,J:J,L:L").Select`

Should do the trick.

v3
guchu 17-Jun-10 9:13am
I have data in columns and each column has 5 rows.. I want to select all the rows of every 4th column say A E I ...
guchu 17-Jun-10 9:15am
and there are 2000 columns like that ...

## Solution 2

Here is the code that does the trick,

```Sub test1()<br />
<br />
Dim i As Integer<br />
Dim j As Integer<br />
Dim a As Double<br />
<br />
<br />
For i = 1 To 10000        ' counter, from 1 to 672<br />
j = 4 * i - 3             ' steps<br />
Sheets("sheet1").Select 'Sheet you get the data from<br />
Cells(1, j).Select<br />
a = Selection<br />
<br />
Sheets("sheet2").Select 'Sheet you want to copy the date to<br />
Cells(1, i).Value = a<br />
<br />
Next i<br />
<br />
<br />
End Sub```