excel vba loops
RH

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Excel VBA loops

Excel VBA loops

resolvedResolved · Low Priority · Version 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:

Screen Splitters in Excel

Screen splitter icons can be set from the ribbon bar, or dragged from the scroll bars. The icon just above the up arrow on the right scroll bar controls the horizontal splitter; the icon to the right of the right arrow on the bottom scroll bar controls the vertical splitter.

These icons can be double-clicked to split the screen at the top left of the cell currently in use.

View all Excel hints and tips


Server loaded in 0.05 secs.