Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Marty Jackson   on Feb 21 In MS Office Category.

  
Question Answered By: Qadriyyah Malik   on Feb 21

I didn't say it was "obvious".. I said it was "intuitive".
Meaning that once you see it, you can figure out how it works!

What we're talking about here is called "Event Programming"
(or "Event Management", or something similar, with the word "Event" in the
title)
Changing a value is an "Event", Changing a SELECTION is an "Event".
Initializing a UserForm is an "Event"... There are lots of "Events".
You just have to figure out which Event you want to use to control how your form
acts.

If you're looking at the userform (in the VBA Editor's "Design" window).
right-click on the form and select "view code".
I think the DEFAULT macro for the form itself is the Initialize event.
If you have the textbox selected, right-click/View Code defaults to the Change
event.
If not, use the pull-down on the top right to find it.
Let's say your userform is called (unimaginatively(grin)) UserForm1.
and your textbox is TextBox1.
your worksheet  is called "Sheet1" and
the cell  you want the value from is Row 4, column  3.

In the Initialize macro, you can use:

UserForm1.TextBox1.Text = WorkSheets("Sheet1").Cells(4,3)

I can't test it right now, I've got a macro running  for the next 90 minutes or
so,
but I'm pretty sure it's .Text, or maybe .Value

You can do the calculation here too. Like:
.Text = WorkSheets("Sheet1").Cells(4,3) - WorkSheets("Sheet1").Cells(4,4)


If you'd like me to take a closer look, send me a file....

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Dialog Box question Or get search suggestion and latest updates.


Tagged: