select cell have that row selected and hide columns that are empty.

  • I have a worksheet with 600 rows and 500 columns. I would like to be able to select a cell have that row selected from column 1 to 500 then have the columns that have empty cells Hidden. I found this code below by Bryce. But it has a fixed to row 1. Thanks.


  • Welcome to the Forum. Please read the Forum Rules to understand how the Forum works and why I have added Code Tags to your post


    All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.Be sure to use them in future posts.


    How to use code tags

    Note: no apostrophe in the tags, just used for demonstration here.

    ['code]


    your code goes between these tags


    ['/code]


    Or, just highlight all of the code and press the <> in the post menu above button to add the code tags.


    Thanks.

  • Try this aternative code

  • Alan, Roy,


    Thank you both for taking the time to answer my question, I'll do better regarding the Code tags in future.

    royUK your code works perfectly, the only issue is that the user is fixed using the range in line 10 ("A58:ADO58") I manually changed that line to one suitable for my sheet and it hid the columns that had empty cells.

    I user needs to be able to select any row and not be fixed to ("A58:ADO58"). Is it possible to replace this ("A58:ADO58") with a manual entry, such click on a cell and use that row.


    Thanks again


    Adrian

  • Maybe Double_Click would be better, a user is less likely to double click a cell accidentally.


    I'm not entirely sure what you mean, but try this

  • Hi, Roy sorry for the delay in answering, I have been off shift. I tried your code after populating some test data in the cell range H5:QF642. It hid every cell regardless of the cell being empty or not. Maybe I wasn't clear enough what I am looking for is, I double click (I like that feature) on row 30 Could be any row from 5 to 642 the result I am looking for is every cell from column H to QF on row 30 that is empty is to be hidden, every cell that is not empty is to be visible. I could double-click on any row and that is the row I need to hide the empty cells. I hope this is a better explanation.

  • Hello,


    To help everybody to visually understand your challenge ... why don't you attach a sample file to illustrate your point ...

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Maybe this


  • Great to have a very clear explanation with your Word document ...:)


    Even better ... why don't you attach your Excel file ...this allow to test the proposed solution ...;)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • If you cannot attach your file ... hope you can adapt following macros ... to your specific situation


    Hope this will help

    :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Once you have tested the macros ... feel free to share your comments

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Carim, That worked so well. Thank you :)


    Very happy to hear this is helping you out :)


    Many Thanks for your Thanks ... AND for the Like :thumbup:

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!