Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA: Running a macro after inserting data using DDE

Status
Not open for further replies.

njitter

Technical User
Sep 4, 2001
122
US
Hello,

i'm transferring data from a database into an Excel sheet using DDE.

The data needs some formatting like setting colums, drawing borders.

What i need Excel to do is run a maco AFTER the data has been placed into the Worksheet with DDE.

I really think this is possible but i have not been able to find a suitable Event for this (there is no OnCreation or something like that.

I really hope someone can put me in the right direction with this one.

Martijn

---
It's never too late to do the Right thing
 
Hi,
I am assuming that you are using Data/Get External Data. True?

If so, control either getting the data or refreshing the data with a CommandButton. So the first thing you do on the click event is either get data or refresh data and then yuoo run your formatting routine etc.

how's that sound? -) Skip,
metzgsk@voughtaircraft.com
 
njitter,
MS has been moving away from DDE for a long time. It is an ancient technology. They continue to support running macros when DDE data arrives, although you won't find it in any current docs.

In the workbook AutoOpen macro (i think thats what it's called, anyway it's the one that runs whenever the workbook is opened) put a line like this:

Code:
Worksheets("Sheet1").OnData = "SomeMacro"

Whenever DDE data changes in Sheet 1 the macro named "SomeMacro" will run. If for any reason you want to turn the behavior off

Code:
Worksheets("Sheet1").OnData = ""

will do it.

HTH Ruairi

Could your manufacturing facility benefit from real time process monitoring? Would you like your employees to be able to see up to the minute goal and actual production?
For innovative, low cost solutions check out my website.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top