count and sum functions

bhaktany

New Member
Joined
Nov 3, 2005
Messages
7
I am trying to use a count and sum functions in a VBA macro. I need to count a number of rows in worksheet1 and enter that value in worksheet 2. Same for the sum function.

Any ideas?
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
the problem being that the count and sum will be a variable. it won't be a constant number from time to time.

this function will be used to generate a part of a funding report that will change from one deal to the next.

sorry i am a beginner in VBA - how would i select the rows if it will be different each time? I will need to count the rows with data in column A until there is a blank in column A.

please help...
 
Upvote 0
Did you ever find a solution to your problem? I am trying to do the same thing and can't figure out how to make it work.

Thank you!
 
Upvote 0
<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> SumEm()
<SPAN style="color:#00007F">Dim</SPAN> Rng <SPAN style="color:#00007F">As</SPAN> Range
<SPAN style="color:#00007F">Set</SPAN> Rng = Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)
<SPAN style="color:#00007F">With</SPAN> Application.WorksheetFunction
    [B1] = .Sum(Rng)
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
<SPAN style="color:#00007F">Set</SPAN> Rng = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>

Puts the sum of column A into cell B1 of the active sheet.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,425
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top