farmerscott
Well-known Member
- Joined
- Jan 26, 2013
- Messages
- 819
- Office Version
- 365
- Platform
- Windows
Hi Everybody,
As per the code below, I have 4 ranges. I would like to find a way to loop thru them, so I can get an average of each.
The code is erroring- as marked.
1. This is part of a bigger code.
2. the variables within the "setting" of the ranges above are providing the correct results.
thanks for the help,
FS.
As per the code below, I have 4 ranges. I would like to find a way to loop thru them, so I can get an average of each.
The code is erroring- as marked.
VBA Code:
Set rng2 = ws.Range("B1:B" & (f - 1))
Set rng3 = ws.Range("B" & f & ":B" & (g - 1))
Set rng4 = ws.Range("B" & g & ":B" & (h - 1))
Set rng5 = ws.Range("B" & h & ":B" & lr)
For i = 1 To 4 Step 1
rng = WorksheetFunction.Choose(i, rng2, rng3, rng4, rng5)
x = WorksheetFunction.Average(rng) [COLOR=rgb(184, 49, 47)]'erroring on this line. "Runtime error 1004"[/COLOR]
Next i
1. This is part of a bigger code.
2. the variables within the "setting" of the ranges above are providing the correct results.
thanks for the help,
FS.