How can I create a worksheet in a routine and set the code name at

K

kataiwo

Gurus please help me out.
How can I create a worksheet in a routine and set the code name at the same
time.
I presently have a routine that ran fine from the immediate window, but
fails when I call it from my form. I got the "out of range" error.
 
N

NickHK

I seem to remember there are some restrictions on this, because some
propertties do not exist in the VBE until they are used.
So if you are creating a WS, whilst it exist in the WB (you can see it), it
does "exist" for the purposes of the VBE.
From the Immediate window it will work, because the VBE is open/visible and
consequently that object must be present.
IIRC, you can call some property/method/anything on the newly created WS
first, then the .CodeName will be available.

NickHK
 
B

Bob Phillips

IIRC, you can call some property/method/anything on the newly created WS
first, then the .CodeName will be available.

Force a recompile

Application.VBE.CommandBars.FindControl(ID:=578).Execute
 

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