Gruppe
Dialog
Problem
Im aktiven Blatt soll eine Schaltfläche an der Position und in der Größe des selektierten Bereiches erstellt werden.
StandardModule: Modul1
Sub SetButton()
Dim btn As Button
Dim dWidth As Double, dHeight As Double
With Selection
dWidth = .Cells(.Cells.Count).Left - _
.Cells(1).Left + .Cells(.Cells.Count).Width
dHeight = .Cells(.Cells.Count).Top - _
.Cells(1).Top + .Cells(.Cells.Count).RowHeight
Set btn = ActiveSheet.Buttons.Add(.Cells(1).Left, _
.Cells(1).Top, dWidth, dHeight)
End With
btn.Caption = "Aufruf"
btn.OnAction = "Message"
End Sub
Sub Message()
MsgBox "Hallo"
End Sub