PDA

View Full Version : [SOLVED] Display Cell Contents - in ListBox



dj44
03-25-2018, 04:01 PM
good day folks,

i had an idea to show my contents in a mini form

if i click on A2 > show the contents of B2 - in my user form ListBox

well I tried to make it work out but, i still dont know where i have gone wrong.

Im not sure if it is a selection change event or something

please do have a look at my workbook

thank you

davis1118
03-25-2018, 04:11 PM
I'm not much of an expert with VBA, but you can select the range of data on the sheet that you want to show in the list box and then right click and "Name a Range". Then in the properties window of the list box under RowSource you can type the name of that range to show the contents in the list box.

dj44
03-25-2018, 04:32 PM
oh yes, I do remember that.
I just wanted to make a help form to display information - becuase in a cell its too tiny to read.
If i click on a cell it will show the offset cell contents.
oh yes thats another idea:think:

davis1118
03-25-2018, 05:53 PM
Sorry, I didn't fully understand what you were trying to do at first. But I understand now, that makes sense. Yeah I think just offsetting from the activecell would be the easiest way to populate the userform.

JKwan
03-26-2018, 06:25 AM
give this a shot
Delete all code from your FORM
Put the following code onto your Data Sheet
if you click onto column A, it will load your help text. The range is set from A2 to A4, change if you want

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Data")

If Not Intersect(Target, Range("A2:A4")) Is Nothing Then
With HelpForm
.ListBox1.Clear
.ListBox1.AddItem ws.Cells(Target.Row, "B")
.Show False
End With
End If
End Sub

dj44
03-26-2018, 09:24 AM
Hello my friend JKwan,


I didnt know how to combine my

Sub Worksheet_SelectionChange(ByVal Target As Range)

with a userform.



List Boxes are very tricky and temperamental.

But no this code has done the trick nicely

I want to make the font size extra large so that I can read the cell content , and make the help form extra large


Thank you for this super code :)

And wishing you a great week and forum to!

dj44
03-26-2018, 09:27 AM
on hindsight i suppose i should have used a textbox, i suppose what ever does the job im happy :grinhalo:

JKwan
03-26-2018, 10:23 AM
ok, combined the code

dj44
03-26-2018, 02:47 PM
Thanks for the help.
I got to get on typing all those help entries now :type

no rest for the wicked :beerchug: