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

#### ronjo

##### New Member
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.

### Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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

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.

Replies
0
Views
493
Replies
3
Views
306
Replies
5
Views
188
Replies
13
Views
661
Replies
3
Views
491

1,216,100
Messages
6,128,824
Members
449,470
Latest member
Subhash Chand

### 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.

### Which adblocker are you using?

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

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