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

Strange Error in execution of this macro

Manan

New Member
Hi All,
When i am running the below macro the results is something wierd. The formulae wise it is calculating thngs correctly but the columns from J to O are not getting values. they are getting populated as balnk but the P column is getting the value , can u please suggest what i did wrong and how to rectify it .

Code:
Sub Dyn()
'
' Dyn Macro
'
'
  Dim strRng As Long
 
  Range("J3").Select
  ActiveCell.FormulaR1C1 = "=ABS(R[-1]C[-5]-R[-2]C[-5])"
  Range("K4").Select
  ActiveCell.FormulaR1C1 = "=R[-2]C[-6]"
  Range("L4").Select
  ActiveCell.FormulaR1C1 = "=ABS(RC[-7]-R[-2]C[-7])"
  Range("M4").Select
  ActiveCell.FormulaR1C1 = "=RC[-1]/(3*SUM(R[-2]C[-3]:RC[-3]))"
  Range("N4").Select
  ActiveCell.FormulaR1C1 = "=RC[-1]*(0.3816-0.2319)+0.2319"
  Range("O4").Select
  ActiveCell.FormulaR1C1 = "=RC[-1]*RC[-1]"
  Range("P4").Select
  ActiveCell.FormulaR1C1 = "=R[-1]C+(RC[-1]*(RC[-11]-R[-1]C))"
  Range("P5").Select
 
  strRng = Range("A" & Rows.Count).End(xlUp).Row
  Range("J3:P3").AutoFill Destination:=Sheets("Sheet2").Range("J3:P" & strRng)
End Sub


I tried the alternate way also but still this is not working . The issue is why the Columns from J to O are coming as blank while P is having correct values as per formulae.

Code:
Sub Dyn()
'
' Dyn Macro
'
'
  Dim strRng As Long
  
  
  Range("J4").FormulaR1C1 = "=ABS(R[-1]C[-5]-R[-2]C[-5])"
  Range("K4").FormulaR1C1 = "=R[-2]C[-6]"
  Range("L4").FormulaR1C1 = "=ABS(RC[-7]-R[-2]C[-7])"
  Range("M4").FormulaR1C1 = "=RC[-1]/(3*SUM(R[-2]C[-3]:RC[-3]))"
  Range("N4").FormulaR1C1 = "=RC[-1]*(0.3816-0.2319)+0.2319"
  Range("O4").FormulaR1C1 = "=RC[-1]*RC[-1]"
  Range("P4").FormulaR1C1 = "=R[-1]C+(RC[-1]*(RC[-11]-R[-1]C))"
  
  strRng = Range("A" & Rows.Count).End(xlUp).Row
  Range("J3:P3").AutoFill Destination:=Sheets("Sheet2").Range("J3:P" & strRng)
End Sub
 
Last edited:
Friends ,

I feel good , with the help of yours and reading the articles i figured out the error in above and now it is working fine :) i feel good this time.
 
Back
Top