Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default How do you run macro automatically each time workbook is saved?

I have a macro that copies some data to another worksheet in the workbook.
It copies the data as values only. (Some of the date in the first worksheet
is result of formulas and I just want the data to be copied) Anyway, how can
I run the macro each time the workbook is saved so that the second worksheet
always has update data in it? Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default How do you run macro automatically each time workbook is saved?

Husker87:

try , PasteSpecial method


Worksheets("Sheet1").Range("A1:D10").Copy
Worksheets("Sheet2").Range("A1").PasteSpecial Paste:=xlPasteValues


--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Husker87" wrote:

I have a macro that copies some data to another worksheet in the workbook.
It copies the data as values only. (Some of the date in the first worksheet
is result of formulas and I just want the data to be copied) Anyway, how can
I run the macro each time the workbook is saved so that the second worksheet
always has update data in it? Any ideas?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 105
Default How do you run macro automatically each time workbook is saved?

Husker87 wrote:
I have a macro that copies some data to another worksheet in the workbook.
It copies the data as values only. (Some of the date in the first worksheet
is result of formulas and I just want the data to be copied) Anyway, how can
I run the macro each time the workbook is saved so that the second worksheet
always has update data in it? Any ideas?


-------------------

You need to write an event driven macro which will call the other routine that
does your actual work. Look in Walkenbach's VBA book, pg 616 for the
"BeforeSave" event and a code example that just a few lines long. I'd reproduce
it here for you, but it's obviously copyrighted.

Bill
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default How do you run macro automatically each time workbook is saved

Thanks for the reply. I think that will work. How do I get the macro to run
each time the workbook is saved or can I get the date to be constantly
updated?

"chijanzen" wrote:

Husker87:

try , PasteSpecial method


Worksheets("Sheet1").Range("A1:D10").Copy
Worksheets("Sheet2").Range("A1").PasteSpecial Paste:=xlPasteValues


--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Husker87" wrote:

I have a macro that copies some data to another worksheet in the workbook.
It copies the data as values only. (Some of the date in the first worksheet
is result of formulas and I just want the data to be copied) Anyway, how can
I run the macro each time the workbook is saved so that the second worksheet
always has update data in it? Any ideas?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 105
Default How do you run macro automatically each time workbook is saved?

Bill Martin wrote:
Husker87 wrote:

I have a macro that copies some data to another worksheet in the workbook.
It copies the data as values only. (Some of the date in the first worksheet
is result of formulas and I just want the data to be copied) Anyway, how can
I run the macro each time the workbook is saved so that the second worksheet
always has update data in it? Any ideas?



-------------------

You need to write an event driven macro which will call the other routine that
does your actual work. Look in Walkenbach's VBA book, pg 616 for the
"BeforeSave" event and a code example that just a few lines long. I'd reproduce
it here for you, but it's obviously copyrighted.

Bill

--------------------

Actually, to avoid a trip to the library there are links on the web you can find
with a Google search on Excel and BeforeSave, or use Google to search this board
for the BeforeSave event. Here are a couple of the links:

http://msdn2.microsoft.com/en-us/lib...eforesave.aspx

http://www.mvps.org/dmcritchie/excel...htm#beforesave

Good luck...

Bill


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default How do you run macro automatically each time workbook is saved

Husker87:

tyr, Link:=True

Worksheets("Sheet1").Range("A1:D10").Copy
Sheets("Sheet2").Range("A1").Activate
ActiveSheet.Paste Link:=True

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Husker87" wrote:

Thanks for the reply. I think that will work. How do I get the macro to run
each time the workbook is saved or can I get the date to be constantly
updated?

"chijanzen" wrote:

Husker87:

try , PasteSpecial method


Worksheets("Sheet1").Range("A1:D10").Copy
Worksheets("Sheet2").Range("A1").PasteSpecial Paste:=xlPasteValues


--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Husker87" wrote:

I have a macro that copies some data to another worksheet in the workbook.
It copies the data as values only. (Some of the date in the first worksheet
is result of formulas and I just want the data to be copied) Anyway, how can
I run the macro each time the workbook is saved so that the second worksheet
always has update data in it? Any ideas?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to run a macro automatically at fixed time interval wyh Excel Discussion (Misc queries) 0 December 24th 10 01:39 AM
Can I schedule a macro to run automatically at a certain time? Colibri_2[_2_] Excel Worksheet Functions 1 February 13th 07 08:39 PM
Run a macro automatically at a certain time Curt D. Excel Worksheet Functions 4 April 28th 06 10:19 PM
Automatically run a macro in time that user wants Kyriaki Excel Programming 2 November 9th 05 12:36 PM
Run a macro each time a workbook is saved donbuz Excel Programming 2 September 16th 04 03:12 PM


All times are GMT +1. The time now is 01:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"