Excel VBA - use the module in book B to update the data in book A

I have 10 XLS, each of which contains several hundred VBA lines that do the same. I want to move this generic code to the 11th XLS, and the remaining 10 will call the code in the 11th XLS. Shared code must have access to all data and worksheets in the calling XLS. This last requirement does not seem to be addressed by other answers to this question on SO. Can I pass XLS worksheets as a parameter or something like that?

+3
source share
2 answers

Instead of putting it in a secondary XLS file, I would recommend creating an XLA file (Excel Add In).

, XLA. XLA , .

XLA . .

+7

, , , .. :

Public Sub CallMe(ByVal oWorkbook as Workbook)

    Dim oWorksheet as Worksheet
    Set oWorksheet = oWorkbook.Worksheets(1)

    ' Do stuff...

End Sub

, , , , 10 , "this", Worksheets(1) .. , oWorkbook.Workbooks(1).

+3

Source: https://habr.com/ru/post/1712021/


All Articles