Counting and Summing with VBA

  • Thread starter Thread starter Martin_Austin
  • Start date Start date
M

Martin_Austin

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
 
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)
 
Back
Top