incorporating C++ in Excel

froggy

New Member
Joined
Aug 10, 2006
Messages
46
Hi,

I am dong a project which is using Ms Excel. It will be mainly collecting datas and plotting graphs as required. However, i would like to extend my curve to a Weibull distribution graph. With this, i would need some computation of my datas and realise that it is much faster to compute them using C++. As such, i would like to ask if there is any method which i could use to export my data (eg. text file) and compute them in C++ and import my result back into Excel so to facilitate the rest of the computation in Excel platform(which i currently have) to achieve my statistical graph.

Thank you.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi froggy,

I'm sure you could implement it the way you describe, i.e., by having a macro write the data to a text file, executing a shell command to run your C++ on it, and read it back into Excel.

But I believe a much better way to do this is to write your C++ code in the form of a subroutine or function that you can call directly from Excel to effectively give Excel the Weibull distribution capability. You can do this by writing the procedure, taking care to use data types (I would think mostly Doubles, which are 8-Byte floating point values) that are supported by both VBA and C++.

Then in your C++ development environment (Studio .NET?) put the procedure or procedures into a DLL (dynamic link library). Virtually all development environments support generating DLLs. Then you can create a VBA interface in Excel using the Define statement, and use the C++ procedure just as if it were a built-in Excel function.

I think you will find this much more satisfactory in the long run, as it eliminates the need to export and import the processed files, and would be much faster.

Damon
 
Upvote 0
Hi Damon,

thank you for the advise. I shall do more research towards the direction which you have gave. Thanks lots lots :-D
 
Upvote 0

Forum statistics

Threads
1,225,312
Messages
6,184,220
Members
453,223
Latest member
Ignition04

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top