Add formula to cells in a column through VB

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

Guest

I have created a form to enter data into a worksheet. Colum 'F' & Column 'H'
are formatted in custom h:mm. In column 'I', I want to put this formula "
=SUM((F2+H2)*1440)/60" (I think.) for every record added through the form.
Column 'I' is not on the form because columns F & H feed to it. The formula
above adds the two times together and converts it to decimal, which is what I
need.

Thanks,
Joel
 
Dim rng As Range
Set rng = Range(Range("F2"), Range("F2").End(xlDown))
Set rng = Intersect(rng.EntireRow, Range("T:T"))
rng.FormulaR1C1 = "=SUM((RC6+RC8)*1440)/60"
 
It assumes you have already entered your data, so add it to the point after
that.

To modify it for a row-by-row formula creation, modify the "rng" object,
something like:

Set rng = CellBeingUpdated
Set rng = Intersect(rng.EntireRow, Range("T:T"))
 
Can I email you directly so I can send you screen prints or the file so you
can see first hand what I am trying to do? I don't understand all the
choices of change, changeselection, activate...

Joel
 
How are F and H being updated?


Jase4now said:
Can I email you directly so I can send you screen prints or the file so
you
can see first hand what I am trying to do? I don't understand all the
choices of change, changeselection, activate...

Joel
 
Why can't you insert the new code into your F&J updating code?

However you set a reference to F, use that in place of the first row:

Set rng = CellBeingUpdated '<- your cell in F.

The remaining code will work.
 

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