+ Reply to Thread
Results 1 to 46 of 46

Change listbox value

Hybrid View

  1. #1
    Registered User
    Join Date
    10-19-2012
    Location
    Assen
    MS-Off Ver
    Excel 2010
    Posts
    81

    Re: Change listbox value

    Quote Originally Posted by jaslake View Post
    Hi Stignone

    I can debug code on my file with my code but I've no way of knowing how to debug your code on your file without seeing your file and your code. Think about it.

    Be happy to help...if I can.
    Attached the original file. In worksheet INPUT BS i have the DATA. Red marked i not want to change only display in listbox. Green marked needs to be changed.

    If you now run the file you will get the error 381.

    Really hope you can help me out.

    Original File.xlsm

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Change listbox value

    Hi Stignone

    See if the attached gets you started. The UserForm loads and the Pages get populated with what appears to be the correct ranges of data. I've done nothing with Formatting.

    Please note, in previous Sample Files your Ranges ALWAYS started at Row 1. In this new File none of the Ranges start at Row 1. So, in these lines of Code
    x = Me.ListBox5.ListIndex + 1    'row index
    none of the Row Indexes will be correct (the wrong row will be changed). I'll play around with this issue a bit today and see if I can resolve it.

    If you have particular items you DON"T want to allow change, change the TextBox Enabled Property to False. See TexBox49 on Page 5 for an example.

    Let me know of issues.
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Change listbox value

    Hi Stignone

    I've added some Public Variables (see Module1) and I've changed the Initialize Event Code to capture the Range Start Row for each of your Page Ranges.
    I've modified the UpDate Button Code for Page 1 and Page 5 (CommandButton12 and CommandButton10); please make the same appropriate modifications on Page 2, 3 and 4 Update Buttons (CommandButton4, CommandButton6 and CommandButton8)

    Let me know of issues.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    10-19-2012
    Location
    Assen
    MS-Off Ver
    Excel 2010
    Posts
    81

    Re: Change listbox value

    Quote Originally Posted by jaslake View Post
    Hi Stignone

    I've added some Public Variables (see Module1) and I've changed the Initialize Event Code to capture the Range Start Row for each of your Page Ranges.
    I've modified the UpDate Button Code for Page 1 and Page 5 (CommandButton12 and CommandButton10); please make the same appropriate modifications on Page 2, 3 and 4 Update Buttons (CommandButton4, CommandButton6 and CommandButton8)

    Let me know of issues.
    Hi John,

    Many thanks for your help works great now... can you maybe help me out with one more issue? i have some rows hidden in my original worksheet. How can i hide these in my listbox? there is thread, but i cant get it implemented in my code

    http://www.excelforum.com/excel-prog...55#post3034455

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Change listbox value

    Hi Stignone

    In the UserForm Initialize Event, for each ListBox, change this line of code
    Private Sub UserForm_Initialize()
        Dim x As Long
        Dim k As Long
        Dim j As Long
        If MultiPage1.Value = 0 Then x = Sheets("INPUT BS").Range("D10:M50").Rows.Count '<--If you change the Range
        Rx1 = 10 '<----------------------------------------------------------------------You Must Change this
        ListBox1.List = Sheets("INPUT BS").Range("D10:M50").SpecialCells(xlCellTypeVisible).Value '<----Change this line
        For k = 1 To x    'rows
            For j = 1 To 10    'columns
                ListBox1.List(k - 1, j - 1) = VBA.Format(ListBox1.List(k - 1, j - 1), "0")
            Next
        Next

  6. #6
    Registered User
    Join Date
    10-19-2012
    Location
    Assen
    MS-Off Ver
    Excel 2010
    Posts
    81

    Re: Change listbox value

    Hi John, I implemented it but what happens is that after after the rows that are hidden it stops showing the rest that is unhidden. So for example rows 1 till 10 are visible, 10 till 50 hidden, 50 till 100 visible. But it only shows not 1 till 10.

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Change listbox value

    Hi Stignone

    You're using Rows 10 to 50 for ListBox1...why are they hidden?

  8. #8
    Registered User
    Join Date
    10-19-2012
    Location
    Assen
    MS-Off Ver
    Excel 2010
    Posts
    81

    Re: Change listbox value

    Quote Originally Posted by jaslake View Post
    Hi Stignone

    You're using Rows 10 to 50 for ListBox1...why are they hidden?
    Hi John in my example i uses D10:M500 so it's stops showing the rest of the rows that are visible after the first hidden rows.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1