Solved

How to loop through range of cells in Excel VBA?

Posted on 2008-09-30
2
954 Views
Last Modified: 2010-05-18
I am trying to use a For LOOP to alternate throught the range of cells in Excell but do not quite remember the syntex.   Here is what i am trying to do:  

On row 1 select first three cells (for example:  A1, B1, C1) and do something with it.  
Then next loop around should select next three cells on Row 1 (example:  D1, E1, F1)  and do somthing with it
Then next loop around should select next three cells on Row 1 (for example: G1, H1, I1) and do something with it.

I sort of started this but do not quite know how to alternate through Range("?1:?1")

For K = 1 To  30
    Range("?1:?3").Select
    Selection.Merge
    ActiveCell.FormulaR1C1 = "Question" & K
 Next K
 
In the place of questions mark not sure what to put...

Any help is appreciated.    
 
0
Comment
Question by:bengoa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 22607035
For K = 1 To  30 Step 3
    Range(Cells(k, 1), Cells(k + 2, 1)).Select
    Selection.Merge
    ActiveCell.FormulaR1C1 = "Question" & K
 Next K
0
 

Author Closing Comment

by:bengoa
ID: 31501610
thank you.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question