Lopp Formula

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to add a formula to a macro and don't know where to being.
Beginning on row 2 and continuing on I have a number in Column J. In column
L I would like to have a formula that is "Column J/100" then in column m have
a second formula that is "Column E * Column L". The number of rows wil vary
but will always begin with row 2 and column I will always contain data. Any
help would be greatly appreciated. Thanks
 
this should help

Sub addformula()

RowNumber = 2
Range("L" & RowNumber).Formula = "=(J" & RowNumber & ")/100"
Range("M" & RowNumber).Formula = "=E" & RowNumber & "* L" & RowNumber

End Sub
 
You don't always have to loop. You can have your code behave like you do when
you select a bunch of cells and type the formula once and then hit ctrl-enter to
fill all the cells in the selection.

Option Explicit
Sub testme()
Dim LastRow As Long
With ActiveSheet
LastRow = .Cells(.Rows.Count, "I").End(xlUp).Row
.Range("L2:L" & LastRow).Formula = "=j2/100"
.Range("M2:M" & LastRow).Formula = "=e2*l2"
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top