Solved

How to loop through range of cells in Excel VBA?

Posted on 2008-09-30
2
944 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

726 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