Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 14th, 2006, 12:25 PM
chp chp is offline
Registered User
 
Join Date: Feb 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Capture cell value before changing it

I'm using the Worksheet_Change event to capture when changes are made to various cells on my spreadsheet (then those trigger various macros). In one case, I need to capture the value that was in the cell before "0" was keyed so I can make some adjustments requiring me to subtract the prior amount from a subtotal.

Typing "0" is what triggers my event...but that's too late. My prior value is gone. I've seen that if this was a Form there is a BeforeUpdate event...but I'm not using a Form...

Any suggestions on how I can capture that value before it is changed?
 
Old March 14th, 2006, 12:31 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

This may be prohibitive, based on how many cells you need to monitor, and there is probably a better way, but what I would do is setup a variable for each cell, or an array of variables for the cell.

On the On_Change event, check to see if the new value is 0, if so you can pull the old value out of the variable and use it, or if it isn't 0, assign the new value to the variable.

Hope that helps,

Mike

Mike
EchoVue.com
 
Old March 15th, 2006, 03:40 PM
chp chp is offline
Registered User
 
Join Date: Feb 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, Mike. I may give this a try. There aren't that many values I'd have to keep up with and should be able to do it fairly easily with an array.

As I'm often told, "a good plan today is better than a perfect plan tomorrow."

Thanks again!

Cinda





Similar Threads
Thread Thread Starter Forum Replies Last Post
editing datagrid and changing cell color upon edit matoaka VS.NET 2002/2003 0 August 11th, 2006 11:04 AM
how to capture right click event of datagrid cell swati_joshi ASP.NET 1.0 and 1.1 Professional 2 April 19th, 2006 02:18 AM
how to capture right click event of datagrid cell swati_joshi ASP.NET 1.0 and 1.1 Basics 0 April 18th, 2006 01:51 AM
Changing Cell-formating in Excel via VBA Gert VB How-To 4 May 10th, 2005 01:56 PM
Dynamically Changing the content of a table cell asdasd Javascript 4 February 18th, 2005 01:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.