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

Run time error 1004, Reference is not valid

sasidhar4

New Member
Hi guys, Could you please help me in solving the run time error 1004, "reference is not valid" in the following code line with text highlighted Red

>>> use code - tags <<<
Code:
Sub UltMoment()

Dim datalist, n, m, i

datalist = Range("Mu_1")
n = UBound(datalist, 1)
m = UBound(datalist, 2)
For i = 1 To m

Range("Mu_1").Cells(n, i).GoalSeek Goal:=0, ChangingCell:=Range("Mu_1").Cells(1, i)

    'SolverOk SetCell:=Range("Mu_1").Cells(n, i), MaxMinVal:=3, ValueOf:=0, ByChange:=Range("Mu_1").Cells(1, i)
    'SolverSolve userfinish:=True
Next i
   
End Sub
 
Last edited by a moderator:
Should
Range("Mu_1").Cells(n, i).GoalSeek Goal:=0, ChangingCell:=Range("Mu_1").Cells(1, i)

be
Range("Mu_1").Cells(n, i).GoalSeek Goal:=0, ChangingCell:=Range("Mu_1").offset(1, i)
 
Should
Range("Mu_1").Cells(n, i).GoalSeek Goal:=0, ChangingCell:=Range("Mu_1").Cells(1, i)

be
Range("Mu_1").Cells(n, i).GoalSeek Goal:=0, ChangingCell:=Range("Mu_1").offset(1, i)
Hi Hui

Thank you so much for your help.
Excel is still throwing reference error even after changing the code as suggested with "offset".


Could you please suggest if there is any other solution?
 
Back
Top