Set range variables without run-time error!

  • Hallo all!


    I'm getting an error 'Runtime Error (91): Object variable or With block variable not set' when running the below code. I'm obviously doing something wrong when I try to set the values for the 'range' variables at the top.


    When I remove the 'As Range' for the 4 range variables, it makes it all the way to the rCell.Offset(0, 1).Formula line, where I then get an error 'Runtime Error (424): Object Required'.


    I can't work out where I've ****** up.


    To set it in context, the procedure is supposed to look at column B, where there is a list of entries starting at B9, determine the last non-blank cell address, and therefore the entire range of the list in column B, and for each non-blank cell in column B, add the lookup formula in column C.


    Can anyone help?


    Much appreciated once again,


    Mr. I R Dunce :stare:



  • Re: Set range variables without run-time error!


    Code
    Sub blah()
    Dim LastRow As Long
        LastRow = Range("B65536").End(xlUp).Row + 1
        
        For x = Range("B" & LastRow).End(xlUp).Row To 9 Step -1
            If IsEmpty(Cells(x, 2)) = "False" Then Cells(x, 3).Formula = "=vlookup(rCell,NoPayCardFile_050712!$A$2:E200,5)"
        Next x
        
    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!