PC Review


Reply
Thread Tools Rate Thread

Add formula to cells in a column through VB

 
 
=?Utf-8?B?SmFzZTRub3c=?=
Guest
Posts: n/a
 
      29th Aug 2007
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
 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      30th Aug 2007
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"


"Jase4now" <(E-Mail Removed)> wrote in message
news:9590A5CB-249A-4817-9045-(E-Mail Removed)...
>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



 
Reply With Quote
 
=?Utf-8?B?SmFzZTRub3c=?=
Guest
Posts: n/a
 
      30th Aug 2007
This looks great, but I can't figure out where to put it.

"-" wrote:

> 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"
>
>
> "Jase4now" <(E-Mail Removed)> wrote in message
> news:9590A5CB-249A-4817-9045-(E-Mail Removed)...
> >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

>
>
>

 
Reply With Quote
 
Guest
Posts: n/a
 
      30th Aug 2007
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"))



"Jase4now" <(E-Mail Removed)> wrote in message
newsFDFC470-C4C2-4168-AEAC-(E-Mail Removed)...
> This looks great, but I can't figure out where to put it.
>
> "-" wrote:
>
>> 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"
>>
>>
>> "Jase4now" <(E-Mail Removed)> wrote in message
>> news:9590A5CB-249A-4817-9045-(E-Mail Removed)...
>> >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

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?SmFzZTRub3c=?=
Guest
Posts: n/a
 
      30th Aug 2007
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



"-" wrote:

> 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"))
>
>
>
> "Jase4now" <(E-Mail Removed)> wrote in message
> newsFDFC470-C4C2-4168-AEAC-(E-Mail Removed)...
> > This looks great, but I can't figure out where to put it.
> >
> > "-" wrote:
> >
> >> 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"
> >>
> >>
> >> "Jase4now" <(E-Mail Removed)> wrote in message
> >> news:9590A5CB-249A-4817-9045-(E-Mail Removed)...
> >> >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
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Guest
Posts: n/a
 
      30th Aug 2007
How are F and H being updated?


"Jase4now" <(E-Mail Removed)> wrote in message
news:6CBF0E2B-FD5A-4E2B-B50D-(E-Mail Removed)...
> 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
>
>
>
> "-" wrote:
>
>> 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"))
>>
>>
>>
>> "Jase4now" <(E-Mail Removed)> wrote in message
>> newsFDFC470-C4C2-4168-AEAC-(E-Mail Removed)...
>> > This looks great, but I can't figure out where to put it.
>> >
>> > "-" wrote:
>> >
>> >> 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"
>> >>
>> >>
>> >> "Jase4now" <(E-Mail Removed)> wrote in message
>> >> news:9590A5CB-249A-4817-9045-(E-Mail Removed)...
>> >> >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
>> >>
>> >>
>> >>

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?SmFzZTRub3c=?=
Guest
Posts: n/a
 
      30th Aug 2007
F & H are included in records added through a userform.

"-" wrote:

> How are F and H being updated?
>
>
> "Jase4now" <(E-Mail Removed)> wrote in message
> news:6CBF0E2B-FD5A-4E2B-B50D-(E-Mail Removed)...
> > 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
> >
> >
> >
> > "-" wrote:
> >
> >> 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"))
> >>
> >>
> >>
> >> "Jase4now" <(E-Mail Removed)> wrote in message
> >> newsFDFC470-C4C2-4168-AEAC-(E-Mail Removed)...
> >> > This looks great, but I can't figure out where to put it.
> >> >
> >> > "-" wrote:
> >> >
> >> >> 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"
> >> >>
> >> >>
> >> >> "Jase4now" <(E-Mail Removed)> wrote in message
> >> >> news:9590A5CB-249A-4817-9045-(E-Mail Removed)...
> >> >> >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
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Guest
Posts: n/a
 
      30th Aug 2007
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.


"Jase4now" <(E-Mail Removed)> wrote in message
news:4AEAE279-45FE-4BDC-B251-(E-Mail Removed)...
>F & H are included in records added through a userform.
>
> "-" wrote:
>
>> How are F and H being updated?
>>
>>
>> "Jase4now" <(E-Mail Removed)> wrote in message
>> news:6CBF0E2B-FD5A-4E2B-B50D-(E-Mail Removed)...
>> > 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
>> >
>> >
>> >
>> > "-" wrote:
>> >
>> >> 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"))
>> >>
>> >>
>> >>
>> >> "Jase4now" <(E-Mail Removed)> wrote in message
>> >> newsFDFC470-C4C2-4168-AEAC-(E-Mail Removed)...
>> >> > This looks great, but I can't figure out where to put it.
>> >> >
>> >> > "-" wrote:
>> >> >
>> >> >> 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"
>> >> >>
>> >> >>
>> >> >> "Jase4now" <(E-Mail Removed)> wrote in message
>> >> >> news:9590A5CB-249A-4817-9045-(E-Mail Removed)...
>> >> >> >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
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum column of cells that already contain a formula engbe Microsoft Excel Misc 2 14th Jun 2008 11:47 AM
Is it possible to make all cells in a column have the same formula? shans91@hotmail.com Microsoft Excel Discussion 8 23rd Dec 2007 08:05 PM
Copy formula to a column of cells =?Utf-8?B?RGVhbg==?= Microsoft Excel Programming 1 9th Jun 2006 12:48 AM
How to apply a formula to all cells in a column Gillian White Microsoft Excel Worksheet Functions 3 29th Mar 2006 09:02 PM
Need formula that will sum cells in a column bases on criteria in other cells. Jim Microsoft Excel Worksheet Functions 3 18th Feb 2006 03:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:46 PM.