Looping through cells that are blank but have formula ?

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
788
Office Version
  1. 365
Platform
  1. Windows
Hi,
having trouble with this one

basically i have a column (J) of cells with the following formula
Code:
=IFERROR(INDEX(B2:$B$10000,MATCH(I2,F2:$F$10000,0)),"")

and i want to write values into all the cells that are blank

something like:
Code:
Sub test()
Dim r As Range
For Each r In Range("J2:J10000")
    If r = "" and r.Offset(0, -1).value < 10 then
    r = r.Offset(0, -1).value + 10
    End If
Next
End Sub

ive tried
if r = 0
if len(r) = 0
if isblank(r)

no luck

any help appreciated
 
Last edited:
Looking at certain names is only going to slow things down. You will still need to loop through 10,000 rows, but will then be making even more checks as you do.
It should only take a couple of seconds with your code. If its taking longer try
Code:
Sub test()
With Application
   .ScreenUpdating = False
   .Calculation = xlCalculationManual
   .EnableEvents = False
End With
Dim r As Range
For Each r In Range("J2:J10000")
    If r.Value = 0 And r.Offset(0, -1).Value > 0 And r.Offset(0, -1).Value < 10 Then
    r = r.Offset(0, -1).Value + 10
    End If
Next
With Application
   .ScreenUpdating = True
   .Calculation = xlCalculationAutomatic
   .EnableEvents = True
End With

End Sub
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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