PDA

View Full Version : Solved: Adding worksheet to blank workbook



SeanJ
08-13-2008, 05:13 AM
Hi again,

I have created a workbook that on open shows a form with a button. I am trying to program the button to add a sheet to the workbook. This part I am having issues with I get "run time error 1004". After the first sheet is created and the next time I open the book I want bypass the added new sheet and view all sheet. :banghead: :dunno

rivate Sub cmdGotoSheet_Click()
Dim newsheet As Worksheet
Set wks = Worksheets.Add
End Sub

What in the world am I doing wrong.

PS I want to figureout how to bypass the add new sheet first before coming to you guys for help.

Bob Phillips
08-13-2008, 05:31 AM
Aside from the fact that the variable names are different and you are missing a P from private, that should work.

SeanJ
08-13-2008, 05:49 AM
Sorry about that copied information wrong. I am still getting "run time error 1004" "method 'sheets' of object_global failed" message.

Private Sub cmdGotoSheet_Click()
Dim newsheet As Worksheet
Set wks = Worksheets.Add

End Sub


It errors out at the Set command. :banghead:

I will try figure out why this is happening. I looked at several examples and they states this to be the right code.

Bob Phillips
08-13-2008, 05:59 AM
As I said, it looks okay, should work, and does work for me.

SeanJ
08-13-2008, 06:09 AM
My workbook was bad. Redid in new workbook and it works.