Hide / unhide rows based on value

Dubz149

New Member
Joined
Sep 18, 2014
Messages
1
Hi guys,

This is my first time actually posting here so here goes:

The question is simple enough (I hope); I have a master spreadsheet that controls two slave spreadsheets. Layout-wise they are more or less identical, the columns are slightly different but the rows are exactly the same. The user fills in the master document, which updates the other two, which are the ones we ultimately issue out. The nature of the document, however, means that not all rows will be filled in on the master document, leaving corresponding blank rows in the slave documents. I’m not fussed about there being blank rows on the master, as it never leaves the computer, but the other two are more critical.

My question, therefore, is, how can I write a macro to automatically hide rows that contain a blank value in a particular cell, and have them unhide if they become filled?

In my particular case, the column which is being updated is column B. The first 7 rows are title etc. so don’t need to be included within the process. The code I have been trying to use so far is:

Private Sub Worksheet_Calculate()
Dim LastRow As Long, c As Range
Application.EnableEvents = False
LastRow = Cells(Cells.Rows.Count, "B").End(xlUp).Row
On Error Resume Next
For Each c In Range("B8:B" & LastRow)
If c.Value = "" Then
c.EntireRow.Hidden = True
ElseIf c.Value <> "" Then
c.EntireRow.Hidden = False
End If
Next
On Error GoTo 0
Application.EnableEvents = True
End Sub

My intention was to input this code into both slave spreadsheets, but so far am only getting row 8 to hide and it seems to not matter if B8 has a value in or not!

I have seen this question posted several times online and normally I manage to fudge the responses to suit my particular case, but this time I’m having no luck. Please let me know what I need to do.

Cheers,
Dubz
 

Some videos you may like

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

OTOTO

Board Regular
Joined
Dec 23, 2013
Messages
209
any luck yet with this? I could use this functionality as well!
 

Watch MrExcel Video

Forum statistics

Threads
1,109,383
Messages
5,528,377
Members
409,817
Latest member
JiNXX9500

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top