Good afternoon,
This is my first time posting a question on this thread but have seen many How To for my Excel projects. I've been using Excel for over 10+ years and VBA about 3 so it's not too often I come across something I cant figure out.
I am trying to insert a variable formula nested within a Do Until Loop. The only variable is LineNumber to move down within a column. I have debugged all the syntax errors but now have a new error: "Run-Time error '1004': Application-defined or object-defined error".
Per the Internet (haha), this error means a variable is not defined yet all are and have values.
The original (functional) formula is below the vba insert code for reference. Please let me know if you have a solution or questions.
Thank you,
Larry
This is my first time posting a question on this thread but have seen many How To for my Excel projects. I've been using Excel for over 10+ years and VBA about 3 so it's not too often I come across something I cant figure out.
I am trying to insert a variable formula nested within a Do Until Loop. The only variable is LineNumber to move down within a column. I have debugged all the syntax errors but now have a new error: "Run-Time error '1004': Application-defined or object-defined error".
Per the Internet (haha), this error means a variable is not defined yet all are and have values.
Code:
Dim LineCount As Integer
Dim LineNumber As Integer
LineNumber = 9
'Due Date & Reccurring & Amount Columns
LineCount = Sheet7.Application.CountA(Range("A9:A500")) - 1 + 8
Do Until LineNumber = LineCount + 1
Cells(LineNumber, 10).Formula = _
"=IF(G" & LineNumber & "="""","""",IF(G" & LineNumber & "=""""Monthly"""",F" & LineNumber & "/12,IF(G" _
& LineNumber & "=""""Deadline"",IF(I" & LineNumber & "="","",F" & LineNumber & "/(MONTH(I" & LineNumber & ")-MONTH(H" _
& LineNumber & ")+1)),F" & LineNumber & ")))"
'=IF(G9="","",IF(G9="Monthly",F9/12,IF(G9="Deadline",IF(I9="","",F9/(MONTH(I9)-MONTH(H9)+1)),F9)))
LineNumber = LineNumber + 1
Loop
The original (functional) formula is below the vba insert code for reference. Please let me know if you have a solution or questions.
Thank you,
Larry