+ Reply to Thread
Results 1 to 21 of 21

edit code for list box only have data

  1. #1
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Ljubljana
    MS-Off Ver
    Office 365
    Posts
    1,054

    edit code for list box only have data

    need to edit the following code that show only data in the range not empty
    not like attached photo

    HTML Code: 
    Attached Images Attached Images

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: edit code for list box only have data

    Hello mazan2010,

    Please attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Ljubljana
    MS-Off Ver
    Office 365
    Posts
    1,054

    Re: edit code for list box only have data

    thanks for your reply
    please kindly find attached file
    Quote Originally Posted by Winon View Post
    Hello mazan2010,

    Please attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Attached Files Attached Files

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: edit code for list box only have data

    Try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  5. #5
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Ljubljana
    MS-Off Ver
    Office 365
    Posts
    1,054

    Re: edit code for list box only have data

    dear Norie
    its work good
    i have note if can make it
    in column E the data with decimal i need in listbox not show decimal number for data in column E
    also can explain how can calculated column width as
    .ColumnWidths = "100;20;50;50;20"
    Quote Originally Posted by Norie View Post
    Try this.
    Please Login or Register  to view this content.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: edit code for list box only have data

    For the first part try this.
    Please Login or Register  to view this content.
    Not sure about the second part, what do you want to base the column widths on?

  7. #7
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Ljubljana
    MS-Off Ver
    Office 365
    Posts
    1,054

    Re: edit code for list box only have data

    i mean what mean in this line

    .ColumnWidths = "100;20;50;50;20"

    also do you can look to button for delete what the error (not delete after show the message)

  8. #8
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Ljubljana
    MS-Off Ver
    Office 365
    Posts
    1,054

    Re: edit code for list box only have data

    also if applicable to show head of the table in list box or not
    Product name Size Batch Volume Number

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: edit code for list box only have data

    This line is setting the widths of the 5 columns, in points (pts)W, in the listbox.
    Please Login or Register  to view this content.
    It sets the first column to a width 100 pts, the second to 20 pts, the 3rd to 50 pts and so on.

    What's the problem with the delete button?

    If you just want to delete without a message try this.
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Ljubljana
    MS-Off Ver
    Office 365
    Posts
    1,054

    Re: edit code for list box only have data

    no i need this message but after press ok nothing is happen (not delete any thing

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: edit code for list box only have data

    When I click the delete button the selected row is deleted from the listbox and the sheet.

  12. #12
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Ljubljana
    MS-Off Ver
    Office 365
    Posts
    1,054

    Re: edit code for list box only have data

    as you can see in my attached photo after click ok nothing is happen but when i use the code without message its work for deletion good but i didn't know why
    Quote Originally Posted by Norie View Post
    When I click the delete button the selected row is deleted from the listbox and the sheet.
    Attached Images Attached Images

  13. #13
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Ljubljana
    MS-Off Ver
    Office 365
    Posts
    1,054

    Re: edit code for list box only have data

    just message coming without any effect

  14. #14
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Ljubljana
    MS-Off Ver
    Office 365
    Posts
    1,054

    Re: edit code for list box only have data

    and can make this message pop
    give yes and not instead of ok only

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: edit code for list box only have data

    Your message box can only return vbOk, not vbYes or anything else.

  16. #16
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Ljubljana
    MS-Off Ver
    Office 365
    Posts
    1,054

    Re: edit code for list box only have data

    ok what about head of table can show in listbox or not

  17. #17
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: edit code for list box only have data

    Not unless you use RowSource to populate the listbox.

  18. #18
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Ljubljana
    MS-Off Ver
    Office 365
    Posts
    1,054

    Re: edit code for list box only have data

    you mean
    instead start from A2 start from A1 in the following line
    Set rngSource = Worksheets("Waiting list").Range("A2:E" & .Range("A" & Rows.Count).End(xlUp).Row)

  19. #19
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: edit code for list box only have data

    No, I mean use the RowSource property of the listbox to populate the listbox.

  20. #20
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Ljubljana
    MS-Off Ver
    Office 365
    Posts
    1,054

    Re: edit code for list box only have data

    im sorry but not know how can do this
    Quote Originally Posted by Norie View Post
    No, I mean use the RowSource property of the listbox to populate the listbox.

  21. #21
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: edit code for list box only have data

    There are 3 main ways to populate a listbox:

    1 using the RowSource property

    2 using List

    3 using AddItem

    For 1 you set the RowSource property of the listbox to a reference to the range you want to populate it with.

    For example if you wanted to populate a listbox, ListBox1 from A1:D20 on Sheet1 you would set the RowSource property to Sheet1!A1:D20.

    That can be done manually but here's the code to do it anyway.
    Please Login or Register  to view this content.
    If you want headers in your listbox you have to use this method to populate it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. edit in code for populate range of cell in list box and code for delete any items
    By mazan2010 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2017, 03:33 PM
  2. Vba code to edit data that changes with a list box
    By grimston in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-08-2017, 07:59 AM
  3. vba code to edit a csv file in notepad and replace data
    By garveyarmy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-25-2017, 12:12 PM
  4. Edit VBA code to get data from multiple sheets
    By leprince2007 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-27-2016, 02:23 AM
  5. find and edit data from list
    By twofootgiant in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-21-2009, 06:34 AM
  6. [SOLVED] using list box to edit or select data
    By BigPig in forum Excel General
    Replies: 4
    Last Post: 02-22-2006, 09:35 PM
  7. using list box to edit or select data
    By BigPig in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-20-2006, 12:15 PM

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