ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create command button with VBA (https://www.excelbanter.com/excel-programming/402495-create-command-button-vba.html)

Les

Create command button with VBA
 
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.
--
Les

joel

Create command button with VBA
 
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


"Les" wrote:

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.
--
Les



All times are GMT +1. The time now is 09:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com