PDA

View Full Version : Unhide Hidden Rows



fiza
04-05-2010, 09:45 AM
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

mdmackillop
04-05-2010, 10:22 AM
Range("A26").Resize(InputBox("Rows to unhide")).EntireRow.Hidden = False

fiza
04-05-2010, 10:27 AM
Thanks for the reply. That was helpful & I appreciate that.

Bob Phillips
04-05-2010, 11:01 AM
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.

fiza
04-06-2010, 10:04 AM
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.

Bob Phillips
04-06-2010, 10:42 AM
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

Bob Phillips
04-06-2010, 10:42 AM
Oops, just thought, doesn't your code already do that?

fiza
04-06-2010, 10:56 AM
Thanks for the help

mdmackillop
04-06-2010, 03:17 PM
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"

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

fiza
04-09-2010, 09:39 AM
thanks mdmackillop