Consulting

Results 1 to 9 of 9

Thread: Display Cell Contents - in ListBox

  1. #1
    VBAX Mentor
    Joined
    Feb 2016
    Location
    I have lived in many places, I love to Travel
    Posts
    413
    Location

    Display Cell Contents - in ListBox

    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
    Attached Files Attached Files
    Cheers for your help

    dj

    'Extreme VBA Newbie in progress - one step at a time - like a tortoise's pace'


  2. #2
    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.

  3. #3
    VBAX Mentor
    Joined
    Feb 2016
    Location
    I have lived in many places, I love to Travel
    Posts
    413
    Location
    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
    Cheers for your help

    dj

    'Extreme VBA Newbie in progress - one step at a time - like a tortoise's pace'


  4. #4
    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.

  5. #5
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    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

  6. #6
    VBAX Mentor
    Joined
    Feb 2016
    Location
    I have lived in many places, I love to Travel
    Posts
    413
    Location
    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!
    Cheers for your help

    dj

    'Extreme VBA Newbie in progress - one step at a time - like a tortoise's pace'


  7. #7
    VBAX Mentor
    Joined
    Feb 2016
    Location
    I have lived in many places, I love to Travel
    Posts
    413
    Location
    on hindsight i suppose i should have used a textbox, i suppose what ever does the job im happy
    Cheers for your help

    dj

    'Extreme VBA Newbie in progress - one step at a time - like a tortoise's pace'


  8. #8
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    ok, combined the code
    Attached Files Attached Files

  9. #9
    VBAX Mentor
    Joined
    Feb 2016
    Location
    I have lived in many places, I love to Travel
    Posts
    413
    Location
    Thanks for the help.
    I got to get on typing all those help entries now

    no rest for the wicked
    Cheers for your help

    dj

    'Extreme VBA Newbie in progress - one step at a time - like a tortoise's pace'


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •