开发者

How to distribute VBA code in Excel? [duplicate]

开发者 https://www.devze.com 2023-04-10 21:06 出处:网络
This question already has answers here: What is the best way to share/distribute Excel macro? [closed]
This question already has answers here: What is the best way to share/distribute Excel macro? [closed] (2 answers) Closed 9 years ago.

I wrote VBA code that updates changes made in Excel to a database (SQL server).

How can I distribute this code to other users?

I stored the changed values in an array using the Worksheet_Change subroutine.

Sub Worksheet_Change(ByVal Target As Range)
   'add value to array
End sub

I also have code to update the database:

Sub update_database()
  'update database
End sub

I stored both subroutines in the sheet1 code.

How can I distribute this macro without the user copying and pasting my code?

I know that I can put my macro in q开发者_StackOverflow中文版uick link. But I don't know how to deal with the Worksheet_Change procedure which I think is bound to the sheet.


Put your code in an Addin and distribute that.

Note: to make the addin respond to all Worksheet_Change events, see How can an Excel Add-In respond to events in any worksheet?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号