using vba to program vba???

lpvdsteen

Board Regular
Joined
Jan 21, 2003
Messages
161
Office Version
  1. 2016
Platform
  1. Windows
Hi,

From within my workbook I create a new workbook with calculations. Since Excel does not have a function to do what I want, I created my own function. This function is called from the new workbook, which is a problem when the original is closed or not available or as I have found even when it is changed.
Is there a way to copy a function (or the code for the function or an entire module) to a module in the new workbook so that it can be adressed rather that the function in the old workbook

Luke
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Yes, right click the module in the VBA Prject Window and select export file. It will save as a file with BAS extension. Open the workbook where you want to import, open VBA and select File|Import File.

hth
 
Upvote 0
Ja, Sorry i was a bit unclear. The problem is I want to use code to copy or write the function, not do it manually

Luke
 
Upvote 0
I could be wrong but I dont think you can programatically do this. Why dont you save the macro in your personal.xls or as an add-in?
 
Upvote 0
The thing is, I have created a duty roster file which is now used in a number of workplaces by people who are wonderfull at pointing me at the problems, (it really is incredible, I test and test and test and find everything correct, and ecpecially one person can sit and do nothng and come across problems.), but have absolutely no Idea what they are doing. The program is so small the it can make duty rosters and do all the calculations for more than a year and still fit on a disk so that it can be transported. That is where the problem of a plug-in comes along. It cannot expect these people to save two files; i would first have to explain what a file is and that would take me too long. That is why I want this program to be self-sufficiënt. I have contemplated writing the entire thing in visual basic as all i do with excel is make use of the layout of the spreadsheet and otherwise try to turn everything I don't want to use off, but I had done so much in VBA that this was the easiëst way.

Luke
 
Upvote 0
Tried it, and worked like a charm except that Norton Antivirus decided I was programming a virus or something. it kicked up saying it found bloodhound.ExcelMacro. Whatever it is, not programming and not using the therefore necessary references leaves a virus-scan blank and I cannot have other computers going berserk saying they found a virus, whether it is there or not.
Weird though, this virus scan pop-up. Has anyone else had this problem?? It seems to be directly related to the reference "Microsoft Visual Basic For Applications Extensibility 5.3"

Luke
 
Upvote 0
I had a similar problem with "bloodhound" once when I copied and pasted code from a website. **** thing caused my fiel to be quarantined twice...
I got around it by typing everything in -- presumably the copy-paste from HTML left some invisible code traces that Norton sniffed out.
Hope this works for you

Denis
 
Upvote 0
I was creating code from within code which is what i wanted to do. Now...I think i will go with what i had, using the function still in the parent workbook. I even tried putting the function on a worksheet and copying the worksheet, but functions on worksheet of course are not accepted. (I kwew that already, but had to try anyway)

Luke
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,850
Members
449,194
Latest member
HellScout

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