0

Any way to use vba to add vba code on a worksheet?

I need to create a worksheet with a button on it that allows people to click on the button to select the report they have and then add a double click function on their report page. And I need to share this file on the server for everyone's use.

After they run this file, they are able to double click on their report page's Range("A1:A10") and jump to sheet2 and auto-filtered by the values of the cells in Range("A1:A10").

I can do the code, just don't know how to add it on their workbook's sheet.

I have been searching for days to find the answer for writing vba by vba, but just no luck.

5
  • Possible duplicate of How to add a button programmatically in VBA next to some sheet cell data? Commented Dec 19, 2017 at 1:35
  • Sounds like you could create it as an add-in. Commented Dec 19, 2017 at 1:36
  • I didn't make it clear. It needs to be idiot proof. Add-in is "too much technique" for them. Ideally, They just need to click a button on my file, select their file on their computer and click Ok, then the function is added on their reports. My problem is I know how to write these code, but don't know how to write it on their reports' sheet(1)'s vba editing section and save it. It's (Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean). It needs to be written on the sheet itself. Commented Dec 19, 2017 at 4:07
  • I just need to open their reports, sheet(1)'s vba editing section, paste those code, and that's it. But how to do it by vba? Commented Dec 19, 2017 at 4:11
  • "I just need to open their reports, sheet(1)'s vba editing section, paste those code, and that's it.": Well this would be possible using Workbook.VBProject Property. But it also is a really big security issue. Thats why this is denied by default. Commented Dec 19, 2017 at 6:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.