How to use Worksheet Change vs. Calculate event

BACKGROUND:
I have found a way to copy cell values from one sheet to another sheet so I can access PREVIOUS cell values.  But using the CHANGE event does not copy the results from formulas.  MSDN says there is a Calculate event, but it does not have the range stuff and I'm not sure how to use it.

QUESTION: How can I copy the formula results from a sheet to another location for reference later, AND REMEMBER WHAT THEY WERE AFTER ONE RECALCULATION?

This will then be used with conditional logic: If my new formula result is > than last result, then do something.  If not, do something else.

Thanks in advance for any help.

SetOldSheet.xls
DWG123Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DevomCommented:
Using the calculate event you can see when a worksheet is calculated (and when automatic calculation is turned on this pretty much guarantees you'll see whenever it changes).  However you cannot see which parts of the sheet actually changed.

If you are only looking at one specific cell, or set of cells, try always keeping a copy of them in another location, then every time the calculate event is triggered do your check.

The calculate event is very touchy and will get triggered every time something in the application is changed if you have any volatile functions i.e. today(), now(), CELL(...) on your worksheet of interest so keep that in mind
0
DevomCommented:
Didn't notice you attached a spreadsheet.  I put in a function for the calculation method, but it is memory intensive (and will only work if every cell is involved in a formula somehow).  You can certainly pare it down a bit if you know something about the range you're looking at.

If this is going to be the final layout of your sheet, I'd recommend the resize function (check out how I changed the commented chunk of code)
SetOldSheet.xls
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DWG123Author Commented:
Devom,

Thank you.  This copies the formula results beatifully.  :-)

When I tried to close the spreadsheet it wanted to recalc before closing and got stuck in a loop.  How do you get out of that (aside from break)?

Would it be better to change the Me.Range to something like ("A1:C20","E1:G20") or to use the Resize(1,20)?

Does the resize tell the computer not to worry about the rest of the sheet and save processing time?

0
DevomCommented:
Infinite loops when dealing with excel events usually mean that the event is triggering itself, though that usually crashes excel.  You can avoid that error by turning off and on application.enableevents.

You're not going to notice a big difference in performance using resize vs defining the range, but a defined range (i.e Me.Range("A1:C20")) should be marginally faster and improves readability.  You really only want to use resize when you don't know the size of your range beforehand.  Both tell the computer to only worry about a certain section of the sheet.
0
DWG123Author Commented:
Thank you for the workable solution, explanation and answers to my follow up question.  I was about to pull out my last few grey hairs until you helped!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.