excel, vba, command button

J

jimx

how do you change a property of a command button that is on sheet 1 o
excel worksheet FROM subroutine in vba?

does the command button have the same properties like in visual basic?
ex:
sub change()
command.caption = "button1"
command.top = 900
end sub

??
thank yo
 
C

Chip Pearson

If the command button is from the Controls tool bar, use code
like

Worksheets("Sheet1").OLEObjects("CommandButton1").Object.Caption
= "Text"

If the command button is from the Forms tool bar, use code like

Worksheets("Sheet1").Buttons("Button 1").Text = "Test"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
T

Tom Ogilvy

worksheets("Sheet1").CommandButton1.Caption = "button1"

Worksheets("Sheet1").CommandButton1.Top = 900

most properties are the same.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top