lezawang
Well-known Member
- Joined
- Mar 27, 2016
- Messages
- 1,805
- Office Version
- 2016
- Platform
- Windows
Hi
I opened bran new excel file then went to vba editor. I see Sheet1(sheet1) and Thisworkbook, inside Project windows. I double clicked sheet1 and started typing this code:
Then I went to excel and inserted Button and assign it to that macro and I ran it and it did work fine.
Then I created a new sheet in excel by clicking on + then I insert another Button and assigned to the same Macro above. To my surprise, it did work? I thought because I wrote the macro inside Sheet1 not Module then that means it only work for Sheet1 not outside sheet1? Any help would be appreciated very much. Thank you.
I opened bran new excel file then went to vba editor. I see Sheet1(sheet1) and Thisworkbook, inside Project windows. I double clicked sheet1 and started typing this code:
Code:
Sub abc()
MsgBox "hello"
End Sub
Then I went to excel and inserted Button and assign it to that macro and I ran it and it did work fine.
Then I created a new sheet in excel by clicking on + then I insert another Button and assigned to the same Macro above. To my surprise, it did work? I thought because I wrote the macro inside Sheet1 not Module then that means it only work for Sheet1 not outside sheet1? Any help would be appreciated very much. Thank you.