Criar Botões em VBA

Insira este código em um novo módulo e tecle F5

Sub Criar_Botões()

Dim botão As Button
Dim bot As Range

ActiveSheet.Buttons.Delete

For i = 1 To 5
Set bot = ActiveSheet.Range(Cells(i, 5), Cells(i, 5))
Set botão = _
ActiveSheet.Buttons.Add(bot.Left, bot.Top, bot.Width, bot.Height)

With botão
.OnAction = "Rotina" & i
.Caption = "Rotina " & i
.Name = "Nome" & i
End With

Next i

End Sub

Nenhum comentário: