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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I Sum a Current Cell into a Variable? 1

Status
Not open for further replies.

Killraven

Technical User
Nov 4, 2002
10
US
Hello all,

I am trying create a macro to select a current cell, and add the value of it to a variable during specific months as it checks through a list of data in Excel. This might be a noobie question, but it has really stumped me. I've checked all my references and searched through these forums. Any help would be greatly appreciated.


Ok, this is in a Do While loop, but isn't the full macro,

If Month(ActiveCell) = 1 Then
ActiveCell.Offset(0, 19).Select
If ActiveCell.Value > 0 Then
BTC = BTC + ActiveCell.Value
BTCCount = BTCCount + 1
End If
ActiveCell.Offset(0, -19).Select
End If

The line that I get an error on is:

BTC = BTC + ActiveCell.Value


I'm trying to keep a running 'total' using BTC as my variable. It doesn't accept 'ActiveCell.Value', I'm not sure why.

Thanks a bunch

DK
 
DK,

This will work...

If Month(ActiveCell) = 1 Then
            mth = ActiveCell.Offset(0, 19).Value
If mth > 0 Then
                BTC = BTC + mth
                BTCCount = BTCCount + 1
End If
End If

Hope this helps. :) Please advise as to how it fits.

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top