Update cells formula

G

Guest

Hello and thank you for at least attempting to answer my question.

I am a pilot, and I am attempting to create a running hours, dollars & cost
per hour log in Excel for each aircraft I fly.

My goal is to have a simple sheet wherein I enter the total of hours in one
unprotected cell, the total dollars spent in the next unprotected cell; then
press the “UPDATE†button that has a macro assigned to it; and the sheet will
add the today hours to the existing protected total hours cell, add the today
dollars to the existing total dollars, and then clear the unprotected
data-entry cells.

I am not sure if this is just too simple, or just too hard; I am pretty good
with Excel, but am stumped here.

Thanks again for at least attempting!
 
D

Don Guillett

how about this macro which could be a change_event macro in the sheet module
to make it automatic when you enter something in range(e4)

Sub newtotals()
Range("f4") = Range("f4") + Range("e4")
Range("e4").Clear
End Sub
 
G

Gord Dibben

Pilot

I personally would advise against the idea of "accumlator" cells.

You have no "paper trail" to consult if an error in entry is made.

You would be better off using a couple of helper columns to enter the data
so's you can keep track of the entries.

That said, here is a simple macro to do what you asked.

Sub additup()
With ActiveSheet
..Range("B1").Value = Range("B1").Value + Range("A1").Value
..Range("B2").Value = Range("B2").Value + Range("A2").Value
..Range("A1,A2").ClearContents
End With
End Sub

Enter the values in A1 and A2 then hit the "Update" button to which you have
assigned the code.

To do this without a button, you can use use event code.

See JE McGimpsey's site for this....

http://www.mcgimpsey.com/excel/accumulator.html


Gord Dibben Excel MVP
 
G

Guest

Thanks, Gord. As I was 'testing' my sheet, I found the short-coming of no
original data to reference. Since I do keep a paper log, not a terrible
issue on this on. BUT, I use spreadsheets for so much more, and have already
used your recommended option on another spreadsheet.

Thanks for your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top