PC Review


Reply
Thread Tools Rate Thread

Add separate values in a Column

 
 
=?Utf-8?B?U3Vl?=
Guest
Posts: n/a
 
      11th Jul 2007
Hi All

I found the following in this forum and adapted it to my needs however I
have a problem - this is a membership annual payment subscription column and
there are
6 different values e.g £30, £15, £13, £10, £5, and Free and those values
could be in any cell in the column is it possible to add them up separately
and place the total values in different text boxes on the userform - Tb6 =
£30 Total Tb5 = £15 Total etc


Private Sub Add1_Click()
Dim ws As Worksheet
Set ws = Worksheets("Members")
Set r = Range("P3:P401")
Count = 0
For Each rr In r
Count = Count + rr.Value
Next
Tb1.Value = Count


End Sub
--
Many Thanks

Sue
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      11th Jul 2007
You can use a formula in a worksheet like:

=countif(P3401,30)
to count the cells that contain 30.

In your code you could use this to count the cells.

sometextbox.value _
= application.countif(worksheets("sheet9999").range("P3401"), 30)

You could multiply this result by 30 to get the total value

or

you could use:
=sumif(p3401,30)
in code:
sometextbox.value _
= application.sumif(worksheets("sheet9999").range("P3401"), 30)

Sue wrote:
>
> Hi All
>
> I found the following in this forum and adapted it to my needs however I
> have a problem - this is a membership annual payment subscription column and
> there are
> 6 different values e.g £30, £15, £13, £10, £5, and Free and those values
> could be in any cell in the column is it possible to add them up separately
> and place the total values in different text boxes on the userform - Tb6 =
> £30 Total Tb5 = £15 Total etc
>
> Private Sub Add1_Click()
> Dim ws As Worksheet
> Set ws = Worksheets("Members")
> Set r = Range("P3:P401")
> Count = 0
> For Each rr In r
> Count = Count + rr.Value
> Next
> Tb1.Value = Count
>
> End Sub
> --
> Many Thanks
>
> Sue


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?U3Vl?=
Guest
Posts: n/a
 
      11th Jul 2007
Hi Dave

Thanks for the all the help -- used the CountIf in code and it worked super
-- got rid of all those different colums for £30 & £15 etc -- all in one now
and can add and multiply values and manipulate them any way I want
--
Many Thanks

Sue


"Dave Peterson" wrote:

> You can use a formula in a worksheet like:
>
> =countif(P3401,30)
> to count the cells that contain 30.
>
> In your code you could use this to count the cells.
>
> sometextbox.value _
> = application.countif(worksheets("sheet9999").range("P3401"), 30)
>
> You could multiply this result by 30 to get the total value
>
> or
>
> you could use:
> =sumif(p3401,30)
> in code:
> sometextbox.value _
> = application.sumif(worksheets("sheet9999").range("P3401"), 30)
>
> Sue wrote:
> >
> > Hi All
> >
> > I found the following in this forum and adapted it to my needs however I
> > have a problem - this is a membership annual payment subscription column and
> > there are
> > 6 different values e.g £30, £15, £13, £10, £5, and Free and those values
> > could be in any cell in the column is it possible to add them up separately
> > and place the total values in different text boxes on the userform - Tb6 =
> > £30 Total Tb5 = £15 Total etc
> >
> > Private Sub Add1_Click()
> > Dim ws As Worksheet
> > Set ws = Worksheets("Members")
> > Set r = Range("P3:P401")
> > Count = 0
> > For Each rr In r
> > Count = Count + rr.Value
> > Next
> > Tb1.Value = Count
> >
> > End Sub
> > --
> > Many Thanks
> >
> > Sue

>
> --
>
> Dave Peterson
>

 
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
Autosum column values, if separate column values equal certain val Hulqscout Microsoft Excel Worksheet Functions 1 5th Nov 2008 06:37 PM
Counting Unique Values That Are Separate by Commas in a Column Rothman Microsoft Excel Misc 2 25th Mar 2008 08:06 PM
find a cell matching separate column and row values =?Utf-8?B?TFFFbmdpbmVlcg==?= Microsoft Excel Worksheet Functions 2 26th Jul 2006 07:10 AM
Adding Values Based on a Separate Column =?Utf-8?B?YmluZGVy?= Microsoft Excel Misc 2 14th Feb 2005 07:17 PM
Multi-column report with text from separate fields flowing down each column Rabi Tripathi Microsoft Access Reports 3 30th Sep 2004 03:23 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:39 AM.