Cell Contents on UserForm

G

Guest

Hello
I have just started working with UserForms and I am trying to put the
contents of a cell on my form as a text box. I have found this question
asked here and this is the answer...

label1.caption = workbooks("myworkbook.xls").worksheets(1).range("a1").Value

Where do I put this to get it to work.
I have created the example partsLocDB.xls as listed at
http://www.contextures.com/tiptech.html.

Can anyone reccomend further reccomendations for examples and help for
userforms?
Thanks!
 
H

Harald Staff

Hi

Most Excel objects (userform, sheet, button, whatever) has multiple
"events", which are empty pre-made macros that run when spesific stuff
happen (gotfocus, exit, keypress, mousedown, click, ...). So WHERE to put
code for something depends entirely on WHEN you want those things to happen.
If you want something fun to happen when the mousepointer moves over a label
then put code for just that in the label's mousemove event.

Real life example: When you type into a textbox then three events fire:
Keydown runs first, you may want to check if it's the Enter key, an arrow
key or something and assign certain actions to those. Then Keypress runs.
You may want to discard non-numeric keys here if numeric entries are what
this box needs. Finally Keyup runs, that key is finished and you may want to
perform a calculation, move data or something.

Suggested reading: Events in VBA help. And lots of testing, this is a pretty
big topic.

HTH. best wishes Harald
 

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