• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA formula not working where there is blank cell in a range

Dokat

Member
Hi,

I am trying to do a calculation by dividing the value in cell "H" with (1+"I") and adding to cell "T". However calculation stops and returns blank cell when there is a blank value in cell H or I.

For Ex: If i want to do calculation for 12,000 rows and cell H1234 has a blank value it only does the calculation thru T1234 and returns blank for rest of the range. Did anyone come across similar issue and has solution for it? Thanks

Code:
Sub lybase()
Dim xlCalc As XlCalculation
On Error GoTo ErrorHandler
xlCalc = Application.Calculation
Application.Calculation = xlCalculationManual
Dim lRow As Long
lRow = Sheets("Source Data").Range("a" & Rows.Count).End(xlUp).Row
For i = 2 To lRow
Cells(i, 20) = Cells(i, 8) / (1 + Cells(i, 9))
Next i
ErrorExit:
    On Error Resume Next
   
    Application.Calculation = xlCalc
    Exit Sub
ErrorHandler:
        Debug.Print Err.Number & vbLf & Err.Description
        Resume ErrorExit
 End Sub
 
Hi:

May be add

Code:
On Error Resume Next

Just before line

Code:
Cells(i, 20) = Cells(i, 8) / (1 + Cells(i, 9))

Thanks
 
Back
Top