Forum Discussion
Debug Error on Macro
- Feb 21, 2019
ROUNDDOWN is a built-in function. The use of it is
=ROUNDDOWN(number, num_of_digit)
The macro you wrote is a procedure to repeatedly insert function/formula into the cell in column U. So, it is not related to whether macro recognize ROUNDDOWN
You may try to change the num_of_digit parameter to see if it works. I thought ROUNDDOWN(A1,0) will gives a value round down to the nearest integer.
Wow, After initiating Calculation mode Everything worked almost perfect except "U" column values did not round down. What do you think is the cause? Does macro recognize the ROUNDDOWN
ROUNDDOWN is a built-in function. The use of it is
=ROUNDDOWN(number, num_of_digit)
The macro you wrote is a procedure to repeatedly insert function/formula into the cell in column U. So, it is not related to whether macro recognize ROUNDDOWN
You may try to change the num_of_digit parameter to see if it works. I thought ROUNDDOWN(A1,0) will gives a value round down to the nearest integer.
- Greg BonaparteFeb 24, 2019Iron Contributor
Thanks Man Fai
Turns out I went back to ROUNDDOWN
Sub Enter_Formulas()
For r = 30 To 33
Range("$U" & r).Formula = "=IF(($S" & r & " > 0)*($R" & r & " > 0.00001), ROUNDDOWN(($Y$17-$Y$18)/$Q" & r & ",0)," & Chr(34) & Chr(34) & ")"
Next rEnd Sub
Above macro works but I get conflict from cell Y18 indirectly conflicting with S30, U30 & V30. I'm wondering if there is a way to tell the macro to disregard the conflict. A value in the "NEXT r" will be modified when "this r" is processed which I believe is the indirect conflict.
- Man Fai ChanFeb 24, 2019Iron Contributor
Greg Bonaparte wrote:I was able t fix the syntax with the following: But troubles remain. Cells are conflicting within the spreadsheet. So my issue is not with the macro. Ill need to investigate the issues outside of macro. Thanks again for you help.
Sub Enter_Formulas()
For r = 30 To 37
Range("$U" & r).Formula = "=SUM($Y$17-$Y$18)"Next r
End Sub
I wonder why you use SUM-function but have the minus sign included. Moreover, if you want to sum two cells, it would be better to use "=Y17+Y18". If you want to sum more cells, SUM-function is useful (E.g. SUM(Y17:Y28)).
- Greg BonaparteFeb 23, 2019Iron Contributor
I was able t fix the syntax with the following: But troubles remain. Cells are conflicting within the spreadsheet. So my issue is not with the macro. Ill need to investigate the issues outside of macro. Thanks again for you help.
Sub Enter_Formulas()
For r = 30 To 37
Range("$U" & r).Formula = "=SUM($Y$17-$Y$18)"Next r
End Sub
- Greg BonaparteFeb 23, 2019Iron Contributor
Thanks so much for your assistance Man Fai. With your help I was able to come really close to the end of a 4 year project. I have removed ROUNDDOWN from the macro and moved it to within cells. I believe I can simplify the process by using SUM instead. However I get a syntax error. See macro below:
Sub Enter_Formulas()
For r = 30 To 37
SUM($Y$17-$Y$18)" & Chr(34) & Chr(34) & ")"
Next rEnd Sub
- Man Fai ChanFeb 21, 2019Iron Contributor
Please see the attachment for the syntax of ROUNDDOWN
- Greg BonaparteFeb 21, 2019Iron Contributor
Hmm, Can you write the formula that rounds down to zero so I can see the full syntax.