Answers to your tech questions
What the Tech logo

Welcome ( Log In | Register )
Easy as 1,2,3!

 
Reply to this topicStart new topic
> Excel 2007 Macro Worksheet_Calculate, Event Trigger issue
Shawn
post Sep 28 2009, 02:41 PM
Post #1


New Member
*

Group: New Member
Posts: 2
Joined: 28-September 09
Member No.: 88,126
Operating System: XP



Hello Helpers!

I have an external data source feeding data into the Excel 2007 using DDE (Dynamic Data Exchange). Since I need to re-capture the data and store it into different places (writing to Access 2007, no issue here), I have to use the macro and event trigger "Worksheet_Calculate". The workbook I have is name "Feeder.xlsm", and the sheet name (with data feed) is called "Data_Feeder".

However, this event trigger has 2 big issues:
1) It fires the macro with various errors whenever I am working on different workbook. My analysis told me it was due to wrong trigger on wrong workbook/worksheet. This lead me to a solution below.

2) I tried fixing the issue (1) with code detector "If Sheets.Item(1).Name = "Data_Feeder" Then ....".

This work, but with another major issue -- When I am working in a seperate Workbook, it seems like the the macro stop working (maybe due to the code detector?), even though I can verify that the workbook Feeder.xlsm and worksheet Data_Feeder is still being fed with live DDE data. Probably due to the code detector sensing the wrong workbook and stop the macro?

Therefore, my question is, is there a better method or trigger event for DDE that would not jeopardize my work on other workbook? Or if you have any suggestion to resolve the Code Detector issue mentioned in (2)?

My last question is, when working in VB/Macro editor, I clearly created and saw that the Macro and codes are for the workbook Feeder.xlsm and worksheet Data_Feeder. But why when I opened another workbook, this would cause various errors! It seems like all these workbooks share the SAME Macro and Codes even though I clearly wrote these codes for 1 particular workbook and worksheet. Is this a bug or my lack of understand of Excel macro? I am a newbie here.

Many Thanks!
Sean

This post has been edited by Shawn: Sep 28 2009, 02:50 PM
Go to the top of the page
 
+Quote Post
Shawn
post Sep 29 2009, 09:22 AM
Post #2


New Member
*

Group: New Member
Posts: 2
Joined: 28-September 09
Member No.: 88,126
Operating System: XP



Helpers,

Don't worry, I already resolved it. I use Workbooks collection to first loop through to ID the correct workbook. The I set a new reference to this correct workbook. From then on, all my calculations are based on sheets from this particular workbook.

All are good. Thanks for stoppin by.
Go to the top of the page
 
+Quote Post
Doug
post Oct 5 2009, 03:30 PM
Post #3


Tech Team
Group Icon

Group: Administrator
Posts: 6,239
Joined: 15-May 05
From: California
Member No.: 32,477
Operating System: Win98, Win2k Pro, XP Pro, XP Home



Thanks for posting that you reached a solution.
Glad you got it sorted.

Best Regards
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   0 pelston 26 19th November 2009 - 11:53 AM
Last post by: pelston
No New Posts   0 packerman1975 71 13th November 2009 - 11:30 AM
Last post by: packerman1975
No New Posts   0 sunter 114 1st November 2009 - 11:11 AM
Last post by: sunter
No New Posts   1 vmanbb 153 13th October 2009 - 08:19 PM
Last post by: appleoddity

RSS Time is now: 21st November 2009 - 12:04 AM
Advertisements do not imply our endorsement of that product or service. The forum is run by volunteers who donate their time and expertise. We make every attempt to ensure that the help and advice posted is accurate and will not cause harm to your computer. However, we do not guarantee that they are accurate and they are to be used at your own risk.
Member site: Alliance of Security Analysis Professionals | UNITE Against Malware
Memory Forums | Auto Repair Forum
© Geeks to Go, Inc. | All Rights Reserved | Privacy Policy