define variable range in a loop

ahadi

New Member
Joined
Jun 23, 2017
Messages
1
Dear friends,
I wish to perform statistical calculations in very huge pool of climate data.
what I need is to define a variable cell addresses and pass them to the formula to compute the output.

for example I have the following as Temperature or pressure in different columns for different days of very long historical data:
Date/hourtemperaturepressurehumidity
2017/6/1 03:00UTC23.3871.221.5
2017/6/2 03:00UTC27.8870.634.8
2017/6/3 3:00UTC26.8873.227.8
................

<tbody>
</tbody>

I wish to write a VBA which computes for example write average of certain number of cells in a columns in a cell and iterate it till the end of worksheet and for all sheets
I want to do exactly the following performance in Iterative loop:

iRow = 1
Do
Range("F32").Select
ActiveCell.FormulaR1C1 = "AvragePres"
Range("G32").Select
ActiveCell.FormulaR1C1 = "=AVERAGE(R[-31]C[-1]:R[-1]C[-1])"
Range("F33").Select
iRow = iRow + 1

Loop While iRow < 1600
in this code I wish to define variable cell address in a loop instead of constant cell address F3 or G32 and F33.

Many Thanks in advance for your kind efforts
Ahadi: vazife@gmail.com
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
just use something similar to your iRow variable...and then you can do this:

Code:
Range("F" & yourFVar)
Range("G" & yourGVar)
Range("F" & yourFVar + 1)

yourFVar = yourFVar + 1
yourGVar = yourGVar + 1
 
Upvote 0
Doesn't look like you need a loop to me. Just fill the formula down.
 
Upvote 0

Forum statistics

Threads
1,216,209
Messages
6,129,517
Members
449,515
Latest member
lukaderanged

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top