Consulting

Results 1 to 10 of 10

Thread: Unhide Hidden Rows

  1. #1

    Wink Unhide Hidden Rows

    Hi anyone!

    I have rows hidden in my sheet with the range A26:A35.

    I need your kind help to modify the following code so that when the macro button is clicked, it would ask me how many rows I want to unhide and then when I write the number of rows in the message box it unhides the number of rows for me.

    The following code actually inserts rows. But I want it to be modified so that it unhides hidden rows.

    Any help would be kindly appreciated.

    I hope I had have made my question clear.

    Thanks for taking your valuable time to read this thread.
    Sub InsertRow()
    Dim Rng, n As Long
    Application.ScreenUpdating = False
    Rng = InputBox("Enter number of rows required.")
    Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(Rng - 1, 0)).Select
    Selection.EntireRow.Insert
    End Sub
    There's no place like HOME
    Regards,
    Fiza

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]Range("A26").Resize(InputBox("Rows to unhide")).EntireRow.Hidden = False
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Thanks for the reply. That was helpful & I appreciate that.
    There's no place like HOME
    Regards,
    Fiza

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I would be careful of getting the input and actioning it all in one action. If the user doesn't enter a number it errors out. Far better IMO to get the input into a variable, test that result, then action it.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    One more question If I may ask.

    Th following code hides empty rows based on the cell value of column "A" from the given range in the code.
          Sub HideEmptyRows()
          Application.ScreenUpdating = False
          Application.Calculation = xlCalculationManual
          Dim rw As Long
          For rw = 18 To 40
              Range("A" & rw).EntireRow.Hidden = (Range("A" & rw) = "")
          Next rw
          Application.Calculation = xlCalculationAutomatic
          Application.ScreenUpdating = True
        End Sub
    I need a modification of the code so that it unhides all the hidden empty rows from the given range in the code.

    Any help would be kindly appreciated.
    There's no place like HOME
    Regards,
    Fiza

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Sub HideEmptyRows()
    Dim rw As Long

    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual

    Rows("18:40").Hidden = False
    For rw = 18 To 40

    Rows(rw).Hidden = (Range("A" & rw).Value2 = "")
    Next rw

    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Oops, just thought, doesn't your code already do that?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    Thanks for the help
    There's no place like HOME
    Regards,
    Fiza

  9. #9
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    These lines will make no real impact upon such code regarding speed of execution in this case. Consider their use rather than inluding them "on principle"

    [VBA]Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  10. #10
    thanks mdmackillop
    There's no place like HOME
    Regards,
    Fiza

Posting Permissions

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