findblank cell in column, insert formula then next blank cell and so on

ronjo

New Member
Joined
Jul 14, 2010
Messages
17
I've searched to no avail. I have a sheet consisting of 7 columns and a variable number of rows. The rows are split at random intervals with an empty row.
I wish to find each blank cell in turn in column G and insert an average function for the range of cells immediately above the blank cell. The range will contain some cells with text.
Please can anyone help?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Try this:

Sub avg_blank()
lr = Range("g" & Rows.Count).End(xlUp).Row
astart = 5 'change 5 to first row of data
For i = 5 To lr + 1 'change 5 to first row of data
If Range("g" & i).Value = "" Then
aend = i - 1
Formu = "=average(g" & astart & ":g" & aend & ")"
Range("g" & i).Value = Formu
astart = i + 1
End If
Next i
End Sub
 
Upvote 0
What can I say - Thank you very much ScottD it is exactly what I was going round in circles trying to solve and works perfectly. Thanks again and kind regards.
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,280
Members
449,149
Latest member
mwdbActuary

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