+ Reply to Thread
Results 1 to 6 of 6

Hide empty cells in this code

  1. #1
    Registered User
    Join Date
    01-13-2014
    Location
    Croatia
    MS-Off Ver
    Excel 2003
    Posts
    19

    Question Hide empty cells in this code

    Hi,

    I have problem,
    Here is code for sorting items alphabetically but it's showing empty cells, how to modify this code to stop showing empty cells?

    Private Sub ComboBox1_DropButtonClick()
    ComboBox1.Clear
    Dim i As Long, j As Long, v As Variant
    Dim tmp As Variant
    v = Range("E2:E1000").Value
    For i = 1 To UBound(v, 1) - 1
    For j = i + 1 To UBound(v, 1)
    If v(i, 1) > v(j, 1) Then
    tmp = v(i, 1)
    v(i, 1) = v(j, 1)
    v(j, 1) = tmp
    End If
    Next
    Next
    ComboBox1.List = v

    I am new to VBA programming and don't know how to do this.

    Thanks.

  2. #2
    Valued Forum Contributor
    Join Date
    12-25-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2016
    Posts
    506

    Re: Hide empty cells in this code

    Hi JanF, try code below in a test sheet first.

    Please Login or Register  to view this content.


    _______________________________________________________________________________________________________________________________
    1. Click on the * Add Reputation if you think someone helped you
    2. Mark your thread as SOLVED when question is resolved

    Alvin

  3. #3
    Registered User
    Join Date
    01-13-2014
    Location
    Croatia
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Hide empty cells in this code

    This code works but it has some little problem,
    I have letters sorted in this direction (this is only for test)

    b
    c
    a
    d
    z

    when I click on drop down button it shows

    a
    empty
    empty
    d
    z

    This code sorts letters but in this example it misses "b" and "c"...
    I don't know where is the problem...

  4. #4
    Valued Forum Contributor
    Join Date
    12-25-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2016
    Posts
    506

    Re: Hide empty cells in this code

    Oops, please change "temp" to "tmp" in the coding



    _______________________________________________________________________________________________________________________________
    1. Click on the * Add Reputation if you think someone helped you
    2. Mark your thread as SOLVED when question is resolved

    Alvin

  5. #5
    Registered User
    Join Date
    01-13-2014
    Location
    Croatia
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Hide empty cells in this code

    Thanks alvin-chung, PROBLEM SOLVED :D

  6. #6
    Valued Forum Contributor
    Join Date
    12-25-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2016
    Posts
    506

    Re: Hide empty cells in this code

    Thank you for the feedback, you're welcome



    _______________________________________________________________________________________________________________________________
    1. Click on the * Add Reputation if you think someone helped you
    2. Mark your thread as SOLVED when question is resolved

    Alvin

+ 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. [SOLVED] Auto hide/unhide rows that have empty cells ( Preferably VBA Code)
    By carlandtina02 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-09-2016, 07:06 PM
  2. VBA code to hide empty rows
    By blaw in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-24-2013, 02:32 PM
  3. [SOLVED] still have empty cell after run Delete empty cells code
    By tuongtu3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-25-2012, 04:28 PM
  4. VBA code to hide empty columns.
    By ms_ex_novice in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-29-2011, 10:43 AM
  5. [SOLVED] simple code hide/show rows with cell = empty, set value or any val
    By ivory_kitten in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-17-2006, 09:30 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