private sub workbook_close()

d0wnt0wn

Well-known Member
Joined
Oct 28, 2002
Messages
771
Hi there I have a formula that runs on work book open to put in todays date if the xls file is named estimate.

If ActiveWorkbook.name = "estimate.xls" Then Range("c1").Formula = "=today()"

how can i set the same range to keep the date thats in it but lose the =today() formula when the workbook closes IF the workbook has been saved under a different name.

cheers

Ken
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
One way to do it would just be to copy and paste special prior to closing. You would just need to copy and paste the coding into your workbook_close sub.

Range("A1").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
 
Upvote 0
ok so i need a code that will do this:

on workbook close

if active sheet ="estimate.xls" then do nothing
if active sheet ="any other name" then
copy and paste the contents of c1 as values only

could someone please help me with this i know what i want just not how to write it

Ken
 
Upvote 0
ahhh its ok... i ut realized that it does not matter if it copy and pastes if the workbook is named estimate.xls because the next time it opens the today() code will run again

the copy paste code is all i need thanks
 
Upvote 0
Change your code, dumping the formula
Code:
If ActiveWorkbook.name = "estimate.xls" Then Range("c1") = Date

lenze
 
Upvote 0

Forum statistics

Threads
1,203,744
Messages
6,057,123
Members
444,906
Latest member
NanaExcel

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