ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hide whole row when cel C3 is 0 (zero) (https://www.excelbanter.com/excel-programming/363973-hide-whole-row-when-cel-c3-0-zero.html)

[email protected]

Hide whole row when cel C3 is 0 (zero)
 
Hello,
Who can help me with this next problem?

I want to hide an whole row when the formula in row C give the anser
"0"
The other row are filled!

Who can give me the code for this?

Greets Berry


Harald Staff

Hide whole row when cel C3 is 0 (zero)
 
Hi Berry

Rightclick the sheet tab, "view code", paste this in:

Private Sub Worksheet_Calculate()
If Me.Range("C3").Value = 0 Then
Me.Columns(3).Hidden = True
Else
Me.Columns(3).Hidden = False
End If
End Sub

HTH. Best wishes Harald

skrev i melding
oups.com...
Hello,
Who can help me with this next problem?

I want to hide an whole row when the formula in row C give the anser
"0"
The other row are filled!

Who can give me the code for this?

Greets Berry




Berry

Hide whole row when cel C3 is 0 (zero)
 
Actually this is how the sheet looks:

Colum C Colum D

T T0601CFI
C C0651CFI
H H0602CFI
0 0
0 0

Now I want to automaticly hide the rows with a zero in colum C and also
the ones with a "C"
Who can help me with this code??

Greets


Berry

Hide whole row when cel C3 is 0 (zero)
 

Hi Herald,

That didn't worked. Nothing happened when I copied the code!

Do you need more info??
Greets


Executor

Hide whole row when cel C3 is 0 (zero)
 
Hi Berry,

You can try this:

Private Sub Worksheet_Calculate()
Dim lRowLoop As Long

For lRowLoop = 1 To UsedRange.Rows.Count
If Cells(lRowLoop, 3).Value = 0 Then
Cells(lRowLoop, 3).EntireRow.Hidden = True
ElseIf Cells(lRowLoop, 3).Value = "C" Then
Cells(lRowLoop, 3).EntireRow.Hidden = True
Else
Cells(lRowLoop, 3).EntireRow.Hidden = False
End If
Next
End Sub

This code will be executed each time the sheet is recalculated.


HTH,


Executor

Berry wrote:
Actually this is how the sheet looks:

Colum C Colum D

T T0601CFI
C C0651CFI
H H0602CFI
0 0
0 0

Now I want to automaticly hide the rows with a zero in colum C and also
the ones with a "C"
Who can help me with this code??

Greets



Berry

Hide whole row when cel C3 is 0 (zero)
 

Hi Wouter,

It is almost working, but now when the sheet is calculating my screen
start tripping, when I Debug the code the sheet mark End if yellow.
Do you know what''s wrong.

Maybe I can send you the file.

Greets


Harald Staff

Hide whole row when cel C3 is 0 (zero)
 
My mistake. I was hiding the C colomn, not row 3. Those things occur when I
post before drinking my first coffee. But something should happen, not
nothing. Ok, try this then

Dim X As Boolean

Private Sub Worksheet_Calculate()
Dim R As Long
If X = True Then Exit Sub
X = True
For R = 1 To Cells(65535, 3).End(xlUp).Row
Select Case Cells(R, 3).Value
Case "", 0, "C"
Me.Rows(R).Hidden = True
Case Else
Me.Rows(R).Hidden = False
End Select
Next
X = False
End Sub

HTH. Best wishes Harald


"Berry" skrev i melding
oups.com...

Hi Herald,

That didn't worked. Nothing happened when I copied the code!

Do you need more info??
Greets




Berry

Hide whole row when cel C3 is 0 (zero)
 

Thanks. This one work fine. Enjoy you coffee.

Cheers


Harald Staff

Hide whole row when cel C3 is 0 (zero)
 
"Berry" skrev i melding
ps.com...

Thanks. This one work fine. Enjoy you coffee.

Cheers


Good. Cheers.
Best wishes Harald



Executor

Hide whole row when cel C3 is 0 (zero)
 
Hi Berry,

I tested it without a C in any of the cells.


Try this:

Private Sub Worksheet_Calculate()
Dim lRowLoop As Long
Application.EnableEvents = False
For lRowLoop = 1 To UsedRange.Rows.Count
If Cells(lRowLoop, 3).Value = 0 Then
Cells(lRowLoop, 3).EntireRow.Hidden = True
ElseIf Cells(lRowLoop, 3).Value = "C" Then
Cells(lRowLoop, 3).EntireRow.Hidden = True
Else
Cells(lRowLoop, 3).EntireRow.Hidden = False
End If
Next
Application.EnableEvents = True
End Sub

HTH,

Executor.

Berry wrote:
Hi Wouter,

It is almost working, but now when the sheet is calculating my screen
start tripping, when I Debug the code the sheet mark End if yellow.
Do you know what''s wrong.

Maybe I can send you the file.

Greets



Berry

Hide whole row when cel C3 is 0 (zero)
 
Hello,

The code is working correct, only 1 problem: There is a auto filter in
de row, when I filter something, It wont work.
Does anyone know what is wrong and what I can do about it.

Thanx for your reply's



All times are GMT +1. The time now is 03:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com