• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Hide and unhide multiple rows in multiple sheets

Hema1309

New Member
I am trying to hide multiple rows in multiple worksheets in the same workbook, but the formula is not working... I think it has to do with the first line. Above this code, I have Worksheet_Change(ByVal Target As Range) for other codes. Thank you so much in advance!

Code:
Private Sub MultipageHideAndUnhideRows()
For Each c In Worksheets("FlatStage").Range("A7:A32")
If c.Value = "" Then
c.EntireRow.Hidden = True
Else
c.EntireRow.Hidden = False
End If
Next
For Each c In Worksheets("Efficiency").Range("A7:A32")
  If c.Value = "" Then
  c.EntireRow.Hidden = True
  Else
  c.EntireRow.Hidden = False
End If
Next
For Each c In Worksheets("DayRate").Range("A7:A10,A14:A22,A25:A25,A28:A39")
  If c.Value = "" Then
  c.EntireRow.Hidden = True
  Else
  c.EntireRow.Hidden = False
End If
Next
For Each c In Worksheets("AddServ").Range("A6:A8,A10:A11,A13:A17,A19:A20,A22:A27,A29:A30,A32:A33,B36:B49,B54:B63")
  If c.Value = "" Then
  c.EntireRow.Hidden = True
  Else
  c.EntireRow.Hidden = False
  End If
Next
For Each c In Worksheets("Enhancement").Range("A6:A7,B10:B10,A12:A13,B16:B16")
  If c.Value = "" Then
  c.EntireRow.Hidden = True
  Else
  c.EntireRow.Hidden = False
  End If
Next
End Sub

MOD EDIT: Placed code in the tags.
 
Last edited by a moderator:
Couple of questions:
- In what way it is not working? Is it giving error or it runs but doesn't give desired results?
- What does the code "Worksheet_Change(ByVal Target As Range)" code do? Does it deal with hiding / unhiding rows in the sheet?

You may also choose to post the workbook.
 
Hi Shrivallabha,

I am attaching the workbook in this response. Initially I had the above code under Private Sub Worksheet_Change(ByVal Target As Range) along with the other codes, however that slowed down the executing of the workbook tremendously. I was told not to place it under there since this particular section of code does not make use of Target parameters in any way. I was advice to run it on demand, by clicking a button. I changed it to a separate section and it doesn't do what it needs to do, which is to hide empty rows in multiple other sheets. Thank you so much!!!
 

Attachments

  • Bid Module-v4.xlsm
    892.1 KB · Views: 5
Hi Hema,

I ran the code by opening VB Editor. It runs without any error and it hides rows as intended.

I am confused. Can you tell me how and when are you running it and it is not working?
 
Back
Top