ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sum Code/Function (https://www.excelbanter.com/excel-programming/297855-sum-code-function.html)

No Name

Sum Code/Function
 
I just wrote this up.

You have to start on the first value in the column you
want to count.

This only counts rows. You can edit it to count columns
if you want,

If you need this to be a Function just change Public Sub
to Function

Brad

Public Sub CountCells()
Dim ColumnVal As Integer, RowVal As Integer, RowValStart
As Integer
Dim SheetLocation As String
Dim CellLocation As String


ColumnVal = ActiveCell.Column
RowVal = ActiveCell.Row
RowValStart = ActiveCell.Row

Do Until Cells(RowVal, ColumnVal) = ""
RowVal = RowVal + 1
Loop

SheetLocation = InputBox("Please enter the Worksheet you
want the count to be placed into. i.e. the name on the
worksheet tab.")
CellLocation = InputBox("Please enter the cell you want
the count to be placed into. i.e W5 or AX2")

Sheets(SheetLocation).Range(CellLocation) = RowVal -
RowValStart

End Sub
-----Original Message-----
Is there a function/code that adds up the ammount of

rows in a worksheet and puts it in another worsheets
cell? Lets say I have a worksheet called 'MRIs in May'
and I want the function/code to add up the rows in that
worsheet starting from cell/row A2 and put that number in
a cell located in another worksheet called 'Totals'.
.



All times are GMT +1. The time now is 06:03 AM.

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