PC Review


Reply
 
 
=?Utf-8?B?TmV3YmllVGVjaA==?=
Guest
Posts: n/a
 
      10th Mar 2007
Hello

I am a newbie and would like to learn.
What can I do if I want to detect any changes made to an excel sheet, make a
copy of it and save the copy to another location? Do I create a batch file, a
VB script, a macro, or what?

Can someone help me please?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      10th Mar 2007
It is called a sheet change event. Below is the VBA help instructions for
the event. this is a VBA macro. the best way of creating the macro is with
the Macro learn function. Excel will generate a macro called MACRO1 (the
number automatically increaments with each new learned macro). Then the code
(not including the first line with the SUB and the last line END SUB) into
the Workbook_SheetChange macro so it automatically runs.

To generate the learn macro
1) Go to the Tools Menu - Macro - Start Recording Macro.
2) Do the copy functions you want to be included in the macro.
3) Stop Recording by going back to the Tools Menu - Maco - Stop Recording.
4) Get the macro. Right click the Tab on the bottom of the worksheet with
the worksheet name. Select view Code. On the VBAProject Window look for
module. the recorded macro will be in the Module folder.
5) Copy the macro.
6) Worksheet change Macros must ber place in the worksheet were they are
required. Look in the VBAProject window for the correct Worksheet. Click
the correct worksheet and a new VBA code window will come up. Paste the code
in this window.
7) The first line of the code starting with SUB has to replaced with the
following line

Private Sub Workbook_SheetChange(ByVal Target As Range)



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

SheetChange Event
See AlsoApplies ToExampleSpecificsOccurs when cells in any worksheet are
changed by the user or by an external link.

Private Sub object_SheetChange(ByVal Sh As Object, ByVal Source As Range)
object Application or Workbook. For more information about using events
with the Application object, see Using Events with the Application Object.

Sh A Worksheet object that represents the sheet.

Source The changed range.

Remarks
This event doesn't occur on chart sheets.

Example
This example runs when any worksheet is changed.

Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Source As Range)
' runs when a sheet is changed
End Su
---------------------------------------------------------------------------------------------


"NewbieTech" wrote:

> Hello
>
> I am a newbie and would like to learn.
> What can I do if I want to detect any changes made to an excel sheet, make a
> copy of it and save the copy to another location? Do I create a batch file, a
> VB script, a macro, or what?
>
> Can someone help me please?

 
Reply With Quote
 
Sharad
Guest
Posts: n/a
 
      10th Mar 2007
Do you mean only a worksheet in a workbook or entire workbook?
In any case I guess you would like to make a copy, when the file is being
saved.

If you want to save copy of only a particular worksheet in a workbook:
Define a Public boolean in a module
Insert a module and at the top write as under:

Public myShtChanged as boolean

In the worksheet_change event procedure write code:

myShtChanged = True

Thenin Workbook_BeforeSave event you can write the code:

Dim myBook as Workbook, myName as String

If myShtChanged Then

Set myBook = Sheet("[name_of_the_sheet_w/o_brackets]").Copy
myName = GetSaveAsFilename
'Above line will prompt user to enter the file name

myBook.SaveAs Filename:=myName
myBook.Close

End if




"NewbieTech" <(E-Mail Removed)> wrote in message
news:F3B3F56F-4B1A-4D05-8BAE-(E-Mail Removed)...
> Hello
>
> I am a newbie and would like to learn.
> What can I do if I want to detect any changes made to an excel sheet, make
> a
> copy of it and save the copy to another location? Do I create a batch
> file, a
> VB script, a macro, or what?
>
> Can someone help me please?



 
Reply With Quote
 
Sharad
Guest
Posts: n/a
 
      10th Mar 2007
Do you mean only a worksheet in a workbook or entire workbook?
In any case I guess you would like to make a copy, when the file is being
saved.

If you want to save copy of only a particular worksheet in a workbook:
Define a Public boolean in a module
Insert a module and at the top write as under:

Public myShtChanged as boolean

In the worksheet_change event procedure write code:

myShtChanged = True

Thenin Workbook_BeforeSave event you can write the code:

Dim myBook as Workbook, myName as String

If myShtChanged Then

Set myBook = Sheet("[name_of_the_sheet_w/o_brackets]").Copy
myName = GetSaveAsFilename
'Above line will prompt user to enter the file name

myBook.SaveAs Filename:=myName
myBook.Close

End if




"NewbieTech" <(E-Mail Removed)> wrote in message
news:F3B3F56F-4B1A-4D05-8BAE-(E-Mail Removed)...
> Hello
>
> I am a newbie and would like to learn.
> What can I do if I want to detect any changes made to an excel sheet, make
> a
> copy of it and save the copy to another location? Do I create a batch
> file, a
> VB script, a macro, or what?
>
> Can someone help me please?



 
Reply With Quote
 
=?Utf-8?B?TmV3YmllVGVjaA==?=
Guest
Posts: n/a
 
      11th Mar 2007
Thank you very much Joel & Sharad.

I'm going to try your suggestions.


"NewbieTech" wrote:

> Hello
>
> I am a newbie and would like to learn.
> What can I do if I want to detect any changes made to an excel sheet, make a
> copy of it and save the copy to another location? Do I create a batch file, a
> VB script, a macro, or what?
>
> Can someone help me please?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Paste failed in excel file migrated from Excel 2003 to Excel Handong Chen Microsoft Excel Crashes 1 4th Mar 2010 06:05 PM
Excel failed to copy properly HTML Table had to copy 1st to word T John Doe Microsoft Excel Crashes 1 3rd Dec 2009 07:44 AM
How copy Excel macros from Excel XP (or before) to Excel 2003? =?Utf-8?B?aXhveWU=?= Microsoft Excel Worksheet Functions 3 3rd Nov 2005 08:28 PM
EXCEL FILE a copy/a copy/a copy ....filename =?Utf-8?B?dmU=?= Microsoft Excel New Users 1 29th Sep 2005 09:12 PM
Excel 2003 Issue with UsedRange.Copy (code works in Excel 2002) TechFirm Microsoft Excel Programming 4 21st Jan 2005 01:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:21 AM.