move variable to next user form

Arie Bos

Board Regular
Joined
Mar 25, 2016
Messages
224
Office Version
  1. 365
Platform
  1. Windows
Hello Excel Masters...

I have a userform A in which a value is entered in a textbox.
Then, a button opens up another user form B where I would like to show that value again in a new textbox in grey, so the user knows this is a copied value, but he should still be able to change it for the next round of calculations.
As this value on user form A is not part of a specific procedure that I could make public, I am not sure how to retrieve that specific value in user form B..

What is the correct procedure to do this?

Many thanks,
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Declare a global variable that holds the value.
 
Upvote 0
Hi Richh,

I put it as follows:
in user form A:
VBA Code:
Option Explicit
    Public SSDOperatingDays As Integer

in user form B
VBA Code:
Option Explicit
Private Sub UserForm_Initialize()
    txtN_SSDOperatingDays.Value = SSDOperatingDays

after opening user form B from a commandbutton on A, error return "Variable not defined", with SSDOperatingDays marked blue

Is this a syntax issue?
 
Upvote 0
I believe that the variable should be declared in a module.
 
Upvote 0
Solution
Hi Richh,

Yes, I found out, and it works, thanks to your suggestion!
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top