Fastest way to create clickable buttons in Excel via VBA
You don't need a separate button for each macro. Setup a list of the macros
in some column. Thenset Data Validation on some cell, say B9, to pick from
the list.
The have an event macro monitor B9 and call the selected macro for you:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("B9"), Target) Is Nothing Then Exit Sub
Application.Run Target.Value
End Sub
--
Gary''s Student - gsnu2007k
"Charles" wrote:
Hi there
I am generating worksheets in VBA with lots of buttons, i.e. cells
that launch a macro when clicked. The neatest way I found so far is to
create a rectangular shape to which I assign an "onaction" property.
The thing is that I need to add a lot of them in a spreadsheet (a few
hundreds at least), and it is slowing down my code significantly.
I was wondering if there wasn't a smarter way to launch theses macro
from excel. I was thinking to adding some events in the sheet, but
that would require to be able to add some code to the sheet via VBA
(the onchange subs), which I am not sure is doable.
Would someone know a faster alternative?
thanks in advance
Charles
|