vbide

Excel VBA store functions or subroutines in an array

我是研究僧i 提交于 2019-11-29 03:36:43
问题 In C/C++, when I have a bunch of functions (pointers), I can store them in an array or a vector and call some of them together in a certain order. Can something similar be done in VBA? Thanks! 回答1: Yes, but I don't recommend it. VBA isn't really built for it. You've tagged this question with Excel, so I will describe how it is done for that Office Product. The general concept applies to most of the Office Suite, but each different product has a different syntax for the Application.Run method.

Import lines of code

戏子无情 提交于 2019-11-27 15:50:08
Can we read scripts or lines of code to a module in vba ? Like we have the include function in php . For example: We store this in Excel somewhere and call the range as xyz line 1 of code line 2 of code line 3 of code Then while running a macro we call this like Sub my_macro() xyz End Sub Basically I want to run a few lines of code repetitively but don't want to create another macro and pass the parameters. RubberDuck This can be done using the Microsoft Visual Basic for Applications Extensibility 5.3 (VBIDE) library. There's some great examples at CPearson.com . I typically use this to insert

Import lines of code

吃可爱长大的小学妹 提交于 2019-11-26 18:33:43
问题 Can we read scripts or lines of code to a module in vba? Like we have the include function in php. For example: We store this in Excel somewhere and call the range as xyz line 1 of code line 2 of code line 3 of code Then while running a macro we call this like Sub my_macro() xyz End Sub Basically I want to run a few lines of code repetitively but don't want to create another macro and pass the parameters. 回答1: This can be done using the Microsoft Visual Basic for Applications Extensibility 5