+ Reply to Thread
Results 1 to 10 of 10

Hide rows based on next row value (number)

  1. #1
    Registered User
    Join Date
    11-27-2019
    Location
    Brisbane , Australia
    MS-Off Ver
    2016
    Posts
    27

    Hide rows based on next row value (number)

    Hi All,

    i'm looking to hide rows based on the following

    in Column C i have numbers that have a gap in between rows for the next set , my request is how do i hide when in a set (like 1 to 5 in the first set) i want to hide 1234 and show the row showing 5 only ....next set is 12 so hide row with 1 and show the 2 etc ....the 1's on their own stay....any clues would be greatly appreciated


    1
    2
    3
    4
    5

    1
    2

    1

    1
    2
    3

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Hide rows based on next row value (number)

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    11-27-2019
    Location
    Brisbane , Australia
    MS-Off Ver
    2016
    Posts
    27

    Re: Hide rows based on next row value (number)

    Hi 6th,

    Thanks for your reply!

    Ran that (changed to C:C)
    nothing happened?

    Code to me looked ok

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Hide rows based on next row value (number)

    Quote Originally Posted by BrisbaneOz View Post
    Ran that (changed to C:C)
    nothing happened?
    Please check the attached file
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-27-2019
    Location
    Brisbane , Australia
    MS-Off Ver
    2016
    Posts
    27

    Re: Hide rows based on next row value (number)

    weird stuff , your sheet works mine doesn't?

    appreciate your help heaps

  6. #6
    Registered User
    Join Date
    11-27-2019
    Location
    Brisbane , Australia
    MS-Off Ver
    2016
    Posts
    27

    Re: Hide rows based on next row value (number)

    Hi 6th

    I worked it out (my data cell had a formula that produced that result 12345 etc) once i copied and pasted special all values your code worked

    Thank you so very much.
    Last edited by BrisbaneOz; 07-30-2020 at 01:16 AM.

  7. #7
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Hide rows based on next row value (number)

    Quote Originally Posted by BrisbaneOz View Post
    weird stuff , your sheet works mine doesn't?
    May be the blank cells which appears as empty cells is not actually blank.

    Copy paste the below formula in a cell
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    In the above formula change the C5 to your blank cell and see what result you get. If it shows True then the cells is actually blank and if it shows False then it is a non blank cell.

  8. #8
    Registered User
    Join Date
    11-27-2019
    Location
    Brisbane , Australia
    MS-Off Ver
    2016
    Posts
    27

    Re: Hide rows based on next row value (number)

    Hi 6th,

    All is well as in post #7


    working perfectly

  9. #9
    Registered User
    Join Date
    11-27-2019
    Location
    Brisbane , Australia
    MS-Off Ver
    2016
    Posts
    27

    Re: Hide rows based on next row value (number)

    Above works perfect, now i am trying to delete rather than hide in the above code by changing

    r.Cells(1).Resize(r.Cells.Count - 1).EntireRow.Hidden = True

    to

    r.Cells(1).Resize(r.Cells.Count - 1).EntireRow.Delete = True


    but does not work , does anyone have any clues?


    lol i'm going crazy - remove the =True and all is good


    please ignore it's early morning in Australia - that's my excuse anyway!
    Last edited by BrisbaneOz; 08-27-2020 at 05:09 PM.

  10. #10
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Hide rows based on next row value (number)

    Glad you fixed it and thanks for the feedback

+ 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. Hide number of rows based on user input
    By Excel108 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-05-2019, 05:31 AM
  2. How to automatically hide/unhide exact number of rows based on a cell's value
    By masud_jahan in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-27-2016, 05:23 AM
  3. Hide Rows/Hide Columns Based on Value in Cell
    By brickwall823 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-24-2015, 02:42 PM
  4. Need Toggle Button to hide/unhide rows based on cell value in non concurrent rows
    By The Phoenix in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-13-2015, 10:49 AM
  5. [SOLVED] First unhide all rows - then hide rows based on specific cell value for a range of cells
    By robbiekh in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-22-2013, 05:46 PM
  6. hide/unhide rows based on a value in cell for every given number
    By hrenolino in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-27-2013, 08:51 AM
  7. hide/unhide rows based on a every number value in cell
    By hrenolino in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-23-2013, 11:29 AM

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