Question : add formula to current macro

Hi Experts

I want to add the following conditions to the current macro. In the same format as shown in the VBA code.

All formaula to start at row 6

1. columns F+H+K = M

2. columns G+H+I = N

3. columns O = M - N

4. columns P = (N/M)-1

Answer : add formula to current macro

Sub Edit_Columns()

Application.ScreenUpdating = False

   Dim lngLastRow As Long
   lngLastRow = Cells(Rows.Count, "d").End(xlUp).Row
   Range("M6:M" & lngLastRow).Value = Evaluate("=F6:F" & lngLastRow & "+H6:H" & lngLastRow & "+K6:K" & lngLastRow)
   Range("N6:N" & lngLastRow).Value = Evaluate("=G6:G" & lngLastRow & "+H6:H" & lngLastRow & "+I6:I" & lngLastRow)
   Range("O6:O" & lngLastRow).Value = Evaluate("=M6:M" & lngLastRow & "-N6:N" & lngLastRow)
   Range("P6:P" & lngLastRow).Value = Evaluate("=M6:M" & lngLastRow & "/N6:N" & lngLastRow & "-1")


Application.ScreenUpdating = True

End Sub


Random Solutions  
 
programming4us programming4us