Thread: Iteration Macro
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Living the Dream Living the Dream is offline
external usenet poster
 
Posts: 151
Default Iteration Macro

Hi Dan

IMO the best way to approach this would be to use VB...

Open your workbook
Hit ALT-F11
Select ( ThisWorkbook )
then go to:
Tools | Insert | Module

Once the module window opens, paste in this code.

.................................................. ......

Sub reCalc_Scores()

Dim mySht As Worksheet
Dim myRng1 As Range, myRng2 As Range, myRng3 As Range
Dim c As Range

Set mySht = Sheets("Sheet1") 'change sheet name to suit
Set myRng1 = mySht.Range("D3:D20") 'change range to suit
Set myRng2 = mySht.Range("I3:I20") 'change range to suit
Set myRng3 = mySht.Range("N3:N20") 'change range to suit

For Each c In myRng1
If c < "" Then
With c
.Value = .Offset(0, 1).Value + .Value
.Offset(0, 1).Value = ""
End With
End If
Next c
For Each c In myRng2
If c < "" Then
With c
.Value = .Offset(0, 1).Value + .Value
.Offset(0, 1).Value = ""
End With
End If
Next c
For Each c In myRng3
If c < "" Then
With c
.Value = .Offset(0, 1).Value + .Value
.Offset(0, 1).Value = ""
End With
End If
Next c

End Sub

.................................................. ................

Please take notice of the comments at the end of the ( SET ) stage,
change the ( Sheet1 ) name to whatever is the name of your worksheet
which is on the tab at the bottom. Then change the range to however many
rows of names you have, I have use up to row 20 but you can go many rows
more so as to include any future additions.

HTH
Mick.