Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic VB help - trying to add some fields together

Status
Not open for further replies.

bhp

MIS
Jul 30, 2002
112
US
Does anyone now the VB code required to sum text fields.
In my example I have 5 seperate text fields that contain numbers and I need to create one "total" field which calculates the total of the values in the 5 fields?
Many - Thanks
 
This should work, you will have to change the addresses of the cells.

Code:
Cells(1,6) = Application.WorksheetFunction.Sum(Range("A1:A5"))

Dave
 
Forgive my very very basic knowledge, but could you give me an example of what a Application.WorksheetFunction.Sum would be?
Many Thanks
 
If you have numbers in column A rows 1 to 5

1
2
3
4
5

and you wrote the code:
Code:
Cells(1,6) = Application.WorksheetFunction.Sum(Range("A1:A5"))

then column A row 6 would have a value of 15.

 
No sorry I do understand that part, but where does the code indicate what text fields are being added together and waht cell is displaying the total?
Regards .......
 
Cell you want to display your total in = Application.WorksheetFunction.Sum (range you want to sum)

 
Many thanks will give this a go!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top