Modeless ánd active

Wil Moosa

Well-known Member
Joined
Aug 11, 2002
Messages
893
I have a userform which is modeless.

The labelbox (label1) refers to Activecell.value.

I'm looking for a way where I can use the mouse to select another cell... while the userform is continious in sight... but also updates the text in label1.

I read somewehere that I could use Worksheet_change to get my update but that was more a clue than a clear solution.

Who can help me here?
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Is this what you mean?

First show the form modeless, something like this:

Code:
Sub showtheform()
UserForm1.Show vbModeless
End Sub

and then depending on how you want to get the values either the Worksheet SelectionChange event or the Worksheet Change event for the sheet you want to pull values from:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
UserForm1.Label1 = Target.Text
End Sub

or

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
UserForm1.Label1 = Target.Text
End Sub
 
Upvote 0
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
PicViewer.Label1 = Target.Text
End sub

Worsk fine, does what it needs to do. Thanks.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
PicViewer.Label1 = Target.Text
PicViewer.Image1 = Target.Image
End sub

Should do the same but also should show the corresponding picture (the text is the full path of the picfile). While the text in the label shows the full path of the pic, the pic remains the same. So no reloading.

The strange thing here is when I select with Enter it does work... but everything (also the enter way) jams when I try to select with the mouse.

I could overcome this by hiding and reopening the userform each time but this slows the process down ánd the reloading is less smooth. Am I overlooking something in the reload process here?
 
Upvote 0
Perhaps:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
PicViewer.Label1 = Target.Text
PicViewer.Image1.Picture = LoadPicture(Target.Text)
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,227
Messages
6,164,723
Members
451,912
Latest member
HMF009

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