refedit control not seen?

D

davegb

I have a userform with a refedit control called reDataStart where the
user inputs where the beginning of the data is. When I try to execute
the macro, I get a compile error that the variable is not defined. But
the control is named.

userf1021Mid.Show vbModeless
Set rColHdr = Range(reDataStrt.Value)

How do I tell VBA that reDataStrt is the control in the userform?
All the examples I could find in the NG didn't mention this being
neccessary. Why is this one different?

Thanks.
 
J

Jim Thomlinson

Perhaps I am seeing this a bit out of context. You show the user form and
then immediately try to set the range object to the RefEdit on that form. Has
the RefEdit been filled in yet? Shouldn't you be setting the range based on a
change in the RefEdit?
 
J

Jim Cone

Controls in the userform do not need the userform prefix to
identify them as long as the code resides in the form module.
If you are in another module then you must specify where the control is...

Set rColHdr = Range(userf1021Mid.reDataStrt.Value)
Do this before unloading the form.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"davegb" <[email protected]>
wrote in message
I have a userform with a refedit control called reDataStart where the
user inputs where the beginning of the data is. When I try to execute
the macro, I get a compile error that the variable is not defined. But
the control is named.

userf1021Mid.Show vbModeless
Set rColHdr = Range(reDataStrt.Value)

How do I tell VBA that reDataStrt is the control in the userform?
All the examples I could find in the NG didn't mention this being
neccessary. Why is this one different?
Thanks.
 
D

davegb

Jim said:
Perhaps I am seeing this a bit out of context. You show the user form and
then immediately try to set the range object to the RefEdit on that form. Has
the RefEdit been filled in yet? Shouldn't you be setting the range based on a
change in the RefEdit?
--

Thanks for your reply. The refedit can't be filled in yet because this
is a compile error. The userform hasn't made it onscreen yet. The
intent of the code is to show the userform, the user fill it in, then
when ok is clicked, come back to the macro and set the variable. I
tried it by setting the variable in the userform code, but now the
macro is somehow invisible to XL. When I try to run the macro from a
tool, I get a "Macro ExtractTop10 not found" error. When I try to run
the macro from the list, nothing happens. The macro box closes, but the
macro doesn't run and there's no error message. It's as if I erased the
macro entirely, but it's still there. Very weird! Is there some other
way to accomplish all this?
 
D

davegb

Jim said:
Controls in the userform do not need the userform prefix to
identify them as long as the code resides in the form module.
If you are in another module then you must specify where the control is...

Set rColHdr = Range(userf1021Mid.reDataStrt.Value)
Do this before unloading the form.

Pretty much what I did. See above post for results.
 

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