Using values from macro to userform

P

Pawan

Hi..

I have created a macro. One variable is defined there as:

dim var1_d as integer
var1_d=200

Then on the userform, I have a textbox (var1) and a checkbox (cvar1) next to
it.
Requirement:
When I click checkbox (cvar1), value of var1_d from macro should get copied
to textbox (var1).

My code is:

Private Sub cvar1_Click()

If cvar1 = True Then
UserForm1.var1.Value = var1_d

End If
End Sub

However it is not working. What is wrong in my code?

Thank you

Pawan
 
B

Bob Phillips

Don't dim the variable in the macro, but declare it at the top of the module
with

Public var1_d As Integer
 
P

Pawan

Great.. I got it.. Thanks .. :)

Bob Phillips said:
Don't dim the variable in the macro, but declare it at the top of the module
with

Public var1_d As Integer

--
__________________________________
HTH

Bob
 

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