ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Counting and Summing with VBA (https://www.excelbanter.com/excel-programming/316527-counting-summing-vba.html)

Martin_Austin

Counting and Summing with VBA
 

Hi everyone, this is my first post, so I wanted to start out saying "He
there!" I'm 22, have done minor programming with HTML, PHP, etc, Acces
and Excel now being my interests, so I thought I'd get a question out o
the way that has been bugging me for the better part of the day.

What I have is a list of data in excel, going from A4:CX (x bein
variable, as it changes daily how long this list is). I want to writ
a macro that will count how many items are in that range, and then su
the items in C4:CX. I don't know how to let VBA know how many row
contain data, so that's where my trouble right now is coming from. I
someone could step me in the right direction, I should be able t
figure out the summing and counting from there.

Thanks, and I'm glad to be here :o

--
Martin_Austi
-----------------------------------------------------------------------
Martin_Austin's Profile: http://www.excelforum.com/member.php...fo&userid=1638
View this thread: http://www.excelforum.com/showthread.php?threadid=27755


Bob Phillips[_6_]

Counting and Summing with VBA
 
How do you know what X is?

Assuming you know that value, then all you need is

mySum = WorksheetFunction.SUM(Range("C4:C" & X)

If you don't know, you could try

cRows = Cells(Rows.Count,"C").End(xlUp).Row
mySum = WorksheetFunction.SUM(Range("C4:C" & cRows)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Martin_Austin" wrote in
message ...

Hi everyone, this is my first post, so I wanted to start out saying "Hey
there!" I'm 22, have done minor programming with HTML, PHP, etc, Access
and Excel now being my interests, so I thought I'd get a question out of
the way that has been bugging me for the better part of the day.

What I have is a list of data in excel, going from A4:CX (x being
variable, as it changes daily how long this list is). I want to write
a macro that will count how many items are in that range, and then sum
the items in C4:CX. I don't know how to let VBA know how many rows
contain data, so that's where my trouble right now is coming from. If
someone could step me in the right direction, I should be able to
figure out the summing and counting from there.

Thanks, and I'm glad to be here :o)


--
Martin_Austin
------------------------------------------------------------------------
Martin_Austin's Profile:

http://www.excelforum.com/member.php...o&userid=16382
View this thread: http://www.excelforum.com/showthread...hreadid=277559





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com