Create command button with VBA

  • Thread starter Thread starter Les
  • Start date Start date
L

Les

Hi All, i have a report that i delete the old sheet and replace it with a new
one. What i would like to do is create a command button with VBA and place it
on the new sheet (ALL LC PARTS) and it must have a comment "BACK" on it the
code for this button would also have to go into the new sheet module.

Any help on this would be much appreciated.
 
Sub test()
Sheets("ALL LC PARTS").Delete
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "ALL LC PARTS"

Set newbutton = ActiveSheet.OLEObjects.Add( _
ClassType:="Forms.CommandButton.1", _
Link:=False, _
DisplayAsIcon:=False, _
Left:=227.25, _
Top:=219, _
Width:=72, _
Height:=24)
newbutton.Object.Caption = "Back"

End Sub
 

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

Back
Top