Selecting Every Fourth Cell in a Column

ForestCalvin

New Member
Joined
Jun 8, 2011
Messages
1
Hi all,

I'm using Excel 2003 on Windows XP
This should not be too difficult but I just do not have experience in VBA.

I want to be able to select a cell and execute a macro that will select every fourth cell after the selected one in that specific column.

Then I would like that command to loop until there are two consecutive empty rows.

So if G12 is selected and I execute the macro, G12, G16, G20, G24, etc. --until there are two empty rows -- will all be selected

That's all I need it to do.

Once selected, I am going to manually copy and paste all of these items into a new worksheet.

Thanks!!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi,

Try this code.
Code:
Sub test()
Dim a As Range, u As Range
Set a = Selection.Resize(1, 1)
Set u = a
Do
    Set a = a(5)
    If (a(2) = "") + (a(3) = "") Then Exit Do
    Set u = Union(u, a)
Loop
u.Select
End Sub
 
Upvote 0
On reflection, probably this one is better for this particular job
Code:
Sub testcode2()
Dim a As Range, b As Range, c As Range
Set a = Selection.Resize(1, 1)
Set c = a
Do
For Each b In Range(a, a(5))
    If (b = "") * (b(2) = "") Then Exit Do
Next
Set a = a(5)
Set c = Union(c, a)
Loop
c.Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,391
Members
452,909
Latest member
VickiS

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top