Excel function to call the strike [the least common multiple]

Excel function to call the strike [the least common multiple]


How does not use mathematical operations directly using the Excel functions take LCM [the least common multiple] 

    Dim xls As Object 'to create an object    

    Set xls = CreateObject ( "Excel.Application") 'was built build Excel Application Example (individual) 

    'Open the atpvbaen.xla ins with Excel workbooks (a collection of objects)

    'Xls.LibraryPath for Excel library folder path -   Note 1

    'Call RunAutoMacros method to perform macro (Macro) -   Note 2

    '1 xlAutoOpen - Note 3

    xls.Workbooks.Open(xls.LibraryPath & "Analysisatpvbaen.xla").RunAutoMacros 1

    'Use atpvbaen.xla gain centralized function obtains the least common multiple LCM 6, 12, 144

    MsgBox xls.Run ( "atpvbaen.xla! LCM", 6, 12, 144) 'Method 1

    'GetMacroRegId achieved macro Login (Registration) ID

    'LCM functions to obtain the least common multiple calculated GetMacroRegId through 6, 12, 144

    MsgBox xls.Run("GetMacroRegId(""lcm"")", 6, 12, 144) ' 方法2   

    xls.Quit 'away; Close Excel

    Set xls = Nothing 'release of Excel application object

By the way, the same way .. if the language itself has no specific mathematical functions, you can use this method to call the Excel function uses

Note 1:

Excel common default path

'Returns the names of folders substituted start

        Application.AltStartupPath     

'(Returns an empty string when the file is not an archive) to return the current path of the workbook

        ActiveWorkbook.Path 

'Now with the current path and file name of the workbook (returns only the name of the temporary file when the file is not an archive)            

        ActiveWorkbook.FullName

'Return stored template where the network path, if the given network path does not exist, this property returns an empty string          

        Application.NetworkTemplatesPath 

'Return stored template area where the path

        Application.TemplatesPath      

'Returns the full path to the Excel program

        Application.Path              

'Return to the default path used when setting or Microsoft Excel files open

        Application.DefaultFilePath      

'Return the full path to the folder Start

        Application.StartupPath          

'The return path of the folder library

        Application.LibraryPath         

'Return path computer (over 2000) COM gain set mounting position of the user

        Application.UserLibraryPath      

'Return path delimiter

        Application.PathSeparator        

Note 2:

There are two automatic macros within Excel, one is Auto_Open, Auto_Close is a

Role: 

When the Excel workbook open contains macros, it will automatically execute Auto_Open, Auto_Close will execute when closed

        However, if the Excel application object through the establishment of a program call (OLE Automation; ActiveX)

        It does not perform Auto_Open, Auto_Close, therefore required to set the execution (operation) through Method RunAutoMacros

Note 3:

RunAutoMacros method

        Workbooks.RunAutoMacros (parameters)

Constant Description

        xlAutoOpen: 1 - automatically turns on the macro

        xlAutoClose: 2 - macros automatically shut down

        xlAutoActivate: 3 - Macro role

        xlAutoDeactivate: 4 - the macro is invalid

Original: Large column  calling Excel functions to strike [the least common multiple]


Guess you like

Origin www.cnblogs.com/chinatrump/p/11512836.html