Setting Userform textbox value from Worksheet_Change

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
788
Office Version
  1. 365
Platform
  1. Windows
Hi,

The following works fine (I'm currently using Userform1 with vbModeless)

Userform1.Textbox1.Value = Target

I just want to know what affect this has when the Userform hasn't been loaded.
It seems nothing happens but is it using memory? Or a bad idea?

Can I check whether the Userform is open

Any help appreciated
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
You could use a Public Boolean variable that is TRUE when form is loaded and FALSE when it isn't

Declare at TOP of a MODULE before all subs (in Module1, Module2 etc)
Code:
Option Explicit

Public UserFormLoaded As Boolean


USERFORM code
Code:
Private Sub UserForm_Activate()
[COLOR=#006400]'when form is acivated[/COLOR]
    UserFormLoaded = True

End Sub

Private Sub CommandButton1_Click()

[COLOR=#006400]'when form is unloaded[/COLOR]
    UserFormLoaded = False
    Unload Me
End Sub

And then test the value of variable UserFormLoaded
Code:
If UserFormLoaded Then MsgBox "Loaded" Else MsgBox "Not Loaded"


This code does nothing if userform is not loaded
Code:
Userform1.Textbox1.Value = Target
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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