![]() |
Cell Contents on UserForm
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("a 1").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! |
Cell Contents on UserForm
Hi Bobby
You can run this when you open the userform in this userform event in the userform module. Private Sub UserForm_Initialize() Me.label1.Caption = Workbooks("myworkbook.xls").Worksheets(1).Range("a 1").Value End Sub See also http://support.microsoft.com/default...b;EN-US;829070 -- Regards Ron de Bruin http://www.rondebruin.nl "Bobby" wrote in message ... 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("a 1").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! |
Cell Contents on UserForm
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 fi 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 "Bobby" skrev i melding ... label1.caption = workbooks("myworkbook.xls").worksheets(1).range("a 1").Value Where do I put this to get it to work. (...) Can anyone reccomend further reccomendations for examples and help for userforms? Thanks! |
All times are GMT +1. The time now is 01:59 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com