Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sue Sue is offline
external usenet poster
 
Posts: 285
Default Add separate values in a Column

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Add separate values in a Column

You can use a formula in a worksheet like:

=countif(P3:p401,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( "P3:p401"), 30)

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

or

you could use:
=sumif(p3:p401,30)
in code:
sometextbox.value _
= application.sumif(worksheets("sheet9999").range("P 3:p401"), 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
Sue Sue is offline
external usenet poster
 
Posts: 285
Default Add separate values in a Column

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(P3:p401,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( "P3:p401"), 30)

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

or

you could use:
=sumif(p3:p401,30)
in code:
sometextbox.value _
= application.sumif(worksheets("sheet9999").range("P 3:p401"), 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula to separate cell values in a column with commas PuffyGrl82 Excel Worksheet Functions 3 May 23rd 13 07:16 PM
Autosum column values, if separate column values equal certain val Hulqscout Excel Worksheet Functions 1 November 5th 08 06:37 PM
Counting Unique Values That Are Separate by Commas in a Column Rothman Excel Discussion (Misc queries) 2 March 25th 08 08:06 PM
find a cell matching separate column and row values LQEngineer Excel Worksheet Functions 2 July 26th 06 07:10 AM
Adding Values Based on a Separate Column binder Excel Discussion (Misc queries) 2 February 14th 05 07:17 PM


All times are GMT +1. The time now is 09:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"