Assign a macro to a button

Copper Contributor

Wondering if someone can help me on this. I have a macro which works perfectly fine when manually triggered or assigning a shortcut key to run it. However, for some strange reason, when i assign the macro to a form control button, the macro does something strange.

The macro is quite complicated but in essence what is meant to do is to save 2 tabs into .txt format. When running the macro from the button, it swaps the names of the 2 files. so fileA.txt has tab B content while fileB.txt has tab A content.

Tried searching around to no avail. Please help. A million Thanks! 

6 Replies

Hi Brandon,

 

To figure out how to help you, we have to see that macro.

Also, we have to know the structure of the workbook, how many sheets in it, and where you put the button?

 

Please save the workbook as .xls format, and upload it here in a reply.

Why .xls?

As the community policy, .xlsm isn't allowed to be uploaded!

Here it is. Appreciate your help. The macro in question is the Sub CreateUploadBtn_Click()

 

Also want to add that Macro worked fine (even by assigning it to a button) with older version of excel. Problem only kicked in when i got upgraded to excel 2016.

Hi Brandon,

 

 

The macro isn't found in this workbook!
It seems it saved in another workbook such as Personal Macro Workbook.

Sorry, my bad. Hopefully this works now.

Hi Brandon,

 

I tried to figure out what the issue was but I could not!

Sorry!

 

I suggest you to ask this community it's the best place to go in such an issue!

No apologies needed. Appreciate your help!! :)