Home » excel » vba – Excel VB Button

vba – Excel VB Button

Posted by: admin May 14, 2020 Leave a comment

Questions:

In the “ActiveSheet.Buttons” I get the size of the buttons but not the text that I want, it only shows “Button 1” (whatever number shows up). Can anyone tell me how to get a custom text in the button?

Sub AT()
    Sheets("134B").Select
    Sheets("New Tab").Visible = True
    Sheets("New Tab").Select
    ActiveSheet.Buttons.Add(0.75, 0.75, 36, 28.5).Select
    ActiveSheet.Buttons.Add(37.5, 0.75, 17.25, 28.5).Select
    ActiveSheet.Buttons.Add(55.5, 0.75, 17.25, 28.5).Select
    ActiveSheet.Buttons.Add(73.5, 0.75, 36, 28.5).Select
    Sheets("New Tab").Copy Before:=Sheets(3)
    Sheets("New Tab").Select
    ActiveWindow.SelectedSheets.Visible = False
    Sheets("New Tab (2)").Select
    ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
    Sheets("DB").Select
    Range("J23").Select
End Sub
How to&Answers:
ActiveSheet.Buttons.Add(0.75, 0.75, 36, 28.5).Caption= "Hi!"