Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

excel vba loops

ResolvedVersion 2003

Maik has attended:
Excel VBA Intro Intermediate course

Excel VBA loops

How do I write a loop to calculate a result for each row in a spreadsheet?

RE: Excel VBA loops

Hi Maik

Thank you for your question.

To work through rows of data in a loop I recommend you use the For Each loop

Example

Dim rngRow as Range
Dim rngData as Range

Set rngData=Range("A2:E44") ' Change to the correct area
For Each rngRow in rngData.Rows
'insert code to manipulate or enquire upon each row
'eg rngRow.cells(1).Interior.Color = vbRed
Next rngRow


Please let me know how you get on.


Laura GB

Wed 28 Jan 2009: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Add Text to Displayed Numbers in Excel 2010

To add text to a number in a cell, you need to go to the Home tab on the Ribbon, and click on the Cells group. Select Format Cells from the drop down menu then Custom from the Category list. In the Type box select General. After the word General, enter a space, then opening quotation marks, then the word you want to type and then closing quotation marks. Click on OK and you have your text!

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.