Modeless ánd active

Wil Moosa

Well-known Member
Joined
Aug 11, 2002
Messages
882
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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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
 

Wil Moosa

Well-known Member
Joined
Aug 11, 2002
Messages
882
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?
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Perhaps:

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

Forum statistics

Threads
1,147,691
Messages
5,742,659
Members
423,746
Latest member
Joaogomes

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
Top