VBA Help Command button

Mortenkamstrup

New Member
Joined
Nov 5, 2016
Messages
26
Hello every one :)

I have a code where i transform some data to a new sheet which i create by a macro. in each new sheet i create a new button will be created with this code:

Dim btn As Button
Dim t As Range

Set t = ActiveSheet.Range(Cells(2, 15), Cells(2, 15))
Set btn = ActiveSheet.Buttons.Add(t.Left, t.Top, t.Width, t.Height)


The idea with the button which i create on each sheet is to assign another macro which i should use later for each sheet, but i dont know how.
something like:
Assign macro to Btn = ModVersion2

and then the macro in modVersion2 should be assign to the button so i later can click the button for use the macro?

Any kind person who can help me? I can share my Excel ark if it would help just need a litle help to how i should do it :)

Thanks alot in advance.
 
Last edited:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
it was worth a shot :)

Unfortunatly i get a message which say: The macro may not be able in which workbook or macro may not be enabled.

If i run the macro by pressing Alt F11 and run it works :)

But thanks for the try and now i get a message then i click the button, do not know if i use the right module form or where the problem are :)

once again thanks for your try and effort :)
 
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,762
Members
449,048
Latest member
excelknuckles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top