![]() |
Using values from macro to userform
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 |
Using values from macro to userform
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 "Pawan" wrote in message ... 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 |
Using values from macro to userform
Great.. I got it.. Thanks .. :-)
"Bob Phillips" wrote: 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 "Pawan" wrote in message ... 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 |
All times are GMT +1. The time now is 08:27 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com