I just stuck on the basics. I want to add a new sheet through a macro and a button in the same. I am unable to make it dynamic. it is giving me an error:
Can anyone help me on the same:
Please Login or Register to view this content.
I just stuck on the basics. I want to add a new sheet through a macro and a button in the same. I am unable to make it dynamic. it is giving me an error:
Can anyone help me on the same:
Please Login or Register to view this content.
far simpler to have a hidden template sheet that you copy when needed.
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
didnt get u man... how to do it??
Just create a sheet with all the controls, formatting & formulas. Save 7 hide it then use code to create a copy when needed.
See the Summary sheet's code here
http://www.excel-it.com/workbook_downloads.htm
Thanks for your help man. But
1) the website link is not working
2) Basically I need to embed the same in another macro... The original macro starts with 2 sheets... and when it starts processing it deletes all other existing sheet.. even if u manually add anything.. it creates around 8-9 sheets for processing the macro and then delete all other sheets.... Keep only the original 2 sheets and a new 1 processed sheets....
So I cant keep anything hidden.... Thats Y i want to create another macro with above functionality...
Is there any solution??
The link is fine.
the solution is not working... can any1 help??
Spend a little time on your replies. If you bother to explain why the solution is not working then maybe you will get some help.Originally Posted by crapmind
Hello Crapmind,
Sub abc()
Dim oWS1 As Worksheet
Set oWS1 = ActiveSheet
Sheets(oWS1).Select
Sheets.Add
Sheets("Sheet4").Select
Sheets("Sheet4").Name = "Tol"
ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False _
, DisplayAsIcon:=False, Left:=345.75, Top:=11.25, Width:=165.75, _
Height:=40.5).Select
Set vObj = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Left:=345.75, Top:=11.25, _
Width:=165.75, Height:=40.5)
Set CmdBtn = vObj.Object 'This is a read only property
CmdBtn.Caption = "Misc Info"
End Sub
I've checked your code and its working fine. From your code ---> Sheets(oWS1).Select just put " " on the sheet name --> Sheets("oWS1").Select
Hope this helps you.
corine
Corine
I think this kind of the problem has been kicked around recently. So check the threads below:
http://www.excelforum.com/showthread.php?t=609667
http://www.excelforum.com/showthread...76#post1812176
? ? ? I like the way how Excel can access system API. Really cool ! ? ? ?
1st to royUK
ur link is still not working.... If you wud have read my problem properly then u wud have understand y the solution is not working.
2nd to corinereyes
Thanks a lot buddy for spending valuable time on this. There is a basic problem in my code. There will not be any Sheet4 or something like that... So macro gives a run-time error whenever it doesnt find Sheet4.. thats y i want to make it dynamic... Can this problem be resolved?? pls help
3rd to bettatronic
I am checking out the threads... Still need to analyse how to incorporate the same into my macro... thanks a lot buddy.. anyways check out my post if u can help me on the same..
Thanks
crapmind
Hi Crapmind,
Try this code.
i have put the code in a command button. See the example file i've attached.Private Sub CommandButton1_Click()
Set NewSheet = Sheets.Add(Type:=xlWorksheet)
NewSheet.Name = "Tol"
With NewSheet
Set vObj = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Left:=345.75, Top:=11.25, _
Width:=165.75, Height:=40.5)
Set CmdBtn = vObj.Object 'This is a read only property
CmdBtn.Caption = "Misc Info"
End With
End Sub
Hope this helps you.
Last edited by corinereyes; 08-13-2007 at 02:34 AM.
The link does work, and if you can't be bothered to explain why creating a hidden template sheet with the button required is not going to work then I won't waste any more time with your problem!Originally Posted by crapmind
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks