application undo on whole range

ndendrinos

Well-known Member
Joined
Jan 17, 2003
Messages
1,694
In [B17:B35] I have formulas
On sheet1 and through code (not manual) I sometimes over type the formula on one or more cells thus losing the formula.
Again using code I then save the data on that sheet onto another sheet and I'm redirected to sheet1.
Is there a way to use:
Code:
Application.EnableEvents = False
    Application.Undo
    Application.EnableEvents = True
at the end of my code to re instate the formulas ?
Presently I have code to type the formula in B17 and drag down to B35

Many thanks
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
The Undo stack is cleared if you run a macro. So you will have to write your own Undo procedure. Why can't you use Paste Special|Values in your code?
 
Upvote 0
Thank you for your response Andrew Poulsom.

Sheet1 is an invoice template
example:
A17 I type qty ordered (let us assume 20)
B17=A17 ( and that saves me from typing in B17.
Code checks to see if there is enough stock to fill this order (most of the time there is) BUT if there is not a form shows advising let us say that there are only 15 in stock and gives me the choice to edit the qty in B17 and "back order" the difference (5) in C17 then creates a back order sheet and redirects me to sheet1 that now has [B17] with "broken" formula
This is why I cannot think of a way to use Paste/Special Values.
To write the undo procedure for a single cell change I think I can do but don't now how to do it for several possible "edits" on [B17:B35]. My question is really is this possible or should I stick with the code I have that reinstates the formulas by typing it in B17 and dragging down?
 
Upvote 0
Correct here is the code I'm using
Code:
Range("B17").Activate
    ActiveCell.FormulaR1C1 = "=RC[-1]"
    Selection.AutoFill Destination:=Range("B17:B35"), Type:=xlFillCopy
 
Upvote 0
Why not use a chang event to put the value you enter in A17 into B17?

Even if you already have come adding a check for a specific cell or small range shouldn't really muck things up too much, honest.:)
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,412
Members
448,959
Latest member
camelliaCase

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top