userform value

G

Guest

I have a userform that when is shown when the user clicks a button. When the
userforms opens I want to show a number in a textfield. However that fails
and the field shows nothing. The number is found in a cell and the number is
then read in to a variable that is to be shown in the userform. Pls help me
with this problem.

Private Sub UserForm1_Initialize()
Set rngErrorMarginCell = Range("d5")
dblErrorMarginal = rngErrorMarginCell.Value
TextBox1.Text = dblErrorMarginal
End Sub
 
B

Bob Phillips

Try qualifying with the worksheet name

Set rngErrorMarginCell =Worksheets("Sheet1").Range("d5")

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

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