Solved

How to loop through range of cells in Excel VBA?

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now