#1   Report Post  
stevepain
 
Posts: n/a
Default Event Macro


Dear all,

I've got a spreadsheet that produces summary information based upon a
table that is updated weekly by a supplier, and then copy and pasted
into the summary spreadsheet.
I would like to run a macro that I currently have assigned to a button
on one of the sheets automatically when the data table from the
supplier is updated. Thus removing the need for the user to click the
button everytime the information (and subsequently the report it
generates) is updated.

How do I do this? I think I need some code somewhere, but I'm a bit of
a code novice!

Thanks,

Steve


--
stevepain
------------------------------------------------------------------------
stevepain's Profile: http://www.excelforum.com/member.php...o&userid=21759
View this thread: http://www.excelforum.com/showthread...hreadid=392857

  #2   Report Post  
mangesh_yadav
 
Posts: n/a
Default


How is the tables updated every week.

Mangesh


--
mangesh_yadav
------------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470
View this thread: http://www.excelforum.com/showthread...hreadid=392857

  #3   Report Post  
Bill Martin -- (Remove NOSPAM from address)
 
Posts: n/a
Default

stevepain wrote:
Dear all,

I've got a spreadsheet that produces summary information based upon a
table that is updated weekly by a supplier, and then copy and pasted
into the summary spreadsheet.
I would like to run a macro that I currently have assigned to a button
on one of the sheets automatically when the data table from the
supplier is updated. Thus removing the need for the user to click the
button everytime the information (and subsequently the report it
generates) is updated.

How do I do this? I think I need some code somewhere, but I'm a bit of
a code novice!

Thanks,

Steve




Here's a snippet of code demonstrating what you want I believe:

Private Sub worksheet_change(ByVal Target As Excel.range)
MsgBox "Cell Changed"
End Sub

You need to place this not in the "Modules" as you normally do, but the
"Microsoft Excel Objects" for the specific sheet you want to monitor for changes.

Good luck...

Bill
  #4   Report Post  
Bill Martin -- (Remove NOSPAM from address)
 
Posts: n/a
Default

stevepain wrote:
Dear all,

I've got a spreadsheet that produces summary information based upon a
table that is updated weekly by a supplier, and then copy and pasted
into the summary spreadsheet.
I would like to run a macro that I currently have assigned to a button
on one of the sheets automatically when the data table from the
supplier is updated. Thus removing the need for the user to click the
button everytime the information (and subsequently the report it
generates) is updated.

How do I do this? I think I need some code somewhere, but I'm a bit of
a code novice!

Thanks,

Steve




Here's a snippet of code demonstrating what you want I believe:

Private Sub worksheet_change(ByVal Target As Excel.range)
Dim ChangeRange As range
Application.EnableEvents = False
Set ChangeRange = range("A1:B2")
If Not Intersect(Target, ChangeRange) Is Nothing Then
MsgBox "Cell within range has changed"
End If
Application.EnableEvents = True
End Sub

You need to place this not in the macro "Modules" as you normally do, but the
"Microsoft Excel Objects" for the specific sheet you want to monitor for
changes. If anything is changed in the range A1:B2 on that sheet, then the code
inside the If/EndIf block will execute.

Good luck...

Bill
  #5   Report Post  
stevepain
 
Posts: n/a
Default


The supplier has a template sheet that is updated, and then copy and
pasted into a data sheet within my summary workbook.


--
stevepain
------------------------------------------------------------------------
stevepain's Profile: http://www.excelforum.com/member.php...o&userid=21759
View this thread: http://www.excelforum.com/showthread...hreadid=392857



  #6   Report Post  
mangesh_yadav
 
Posts: n/a
Default


Then maybe you can call that macro (attached to the button) at
workbook_close event.

This event goes in the This_Workbook module. You will have to take care
that if you open the book sometime when you are not updating, even then
this will be fired.


Mangesh


--
mangesh_yadav
------------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470
View this thread: http://www.excelforum.com/showthread...hreadid=392857

  #7   Report Post  
Mangesh Yadav
 
Posts: n/a
Default

Hi Bill / Stevepain

You have to be careful, as for every change in the cell value, your "button
macro" will be triggered when you use the Change event.

MAngesh




"Bill Martin -- (Remove NOSPAM from address)"
wrote in message ...
stevepain wrote:
Dear all,

I've got a spreadsheet that produces summary information based upon a
table that is updated weekly by a supplier, and then copy and pasted
into the summary spreadsheet.
I would like to run a macro that I currently have assigned to a button
on one of the sheets automatically when the data table from the
supplier is updated. Thus removing the need for the user to click the
button everytime the information (and subsequently the report it
generates) is updated.

How do I do this? I think I need some code somewhere, but I'm a bit of
a code novice!

Thanks,

Steve




Here's a snippet of code demonstrating what you want I believe:

Private Sub worksheet_change(ByVal Target As Excel.range)
Dim ChangeRange As range
Application.EnableEvents = False
Set ChangeRange = range("A1:B2")
If Not Intersect(Target, ChangeRange) Is Nothing Then
MsgBox "Cell within range has changed"
End If
Application.EnableEvents = True
End Sub

You need to place this not in the macro "Modules" as you normally do, but

the
"Microsoft Excel Objects" for the specific sheet you want to monitor for
changes. If anything is changed in the range A1:B2 on that sheet, then

the code
inside the If/EndIf block will execute.

Good luck...

Bill



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
Macro triggered by an event AussieAVguy Excel Discussion (Misc queries) 2 June 16th 05 05:51 AM
Help with macro looping and color query function kevinm Excel Discussion (Misc queries) 10 May 26th 05 01:25 AM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 11:12 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 01:40 AM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 05:46 PM


All times are GMT +1. The time now is 04:22 PM.

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"