help with code to automatically hid rows if a cell is empty

bleeet

Board Regular
Joined
May 11, 2009
Messages
208
Office Version
  1. 2013
Platform
  1. Windows
hello

i am not good with VBA but i want to make a code in one of of the pages in my excel file so that if nothing appears in a cell in the range of C4 to C23 then the row is automatically hidden and and if something appears the row unhides

dunno if this matters but those cells will show info that come from info on another sheet.

i saw this code on another thread here but i don't know how to adjust this to fit my setting


Private Sub Worksheet_Calculate()
Dim i As Long
For i = 9 To 53
Rows(i).Hidden = Range("A" & i).Value = ""
Next i
End Sub

if anyone knwo how to do this or advice on a better idea please help

i hope you guys understand what i am saying
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Maybe

Code:
Private Sub Worksheet_Calculate()
Dim i As Long
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Me.Unprotect password:="password"
For i = 4 To 23
    If Not IsError(Range("C" & i)) Then
        Rows(i).Hidden = Range("C" & i).Value = ""
    End If
Next i
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Me.Protect password:="password"
End Sub

sorry another problem again VoG

when i open the work book it prompts me with a window saying "file error: data may have been lost"

and on the same sheet i put this formula on all of my title headings to "open unit"

would you happen to know what the problem is and how i can fix it?

thanks
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,738
Members
452,940
Latest member
Lawrenceiow

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top