Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default 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




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default 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



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Hide whole row when cel C3 is 0 (zero)


Thanks. This one work fine. Enjoy you coffee.

Cheers

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default 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


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default 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




  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you hide/un-hide the grid lines ED Excel Discussion (Misc queries) 4 February 26th 13 03:22 PM
Want to Hide columns in spreadsheet but NOT hide data in chart. KrispyData Charts and Charting in Excel 1 March 20th 09 04:45 PM
hide code does not hide Wanna Learn Excel Discussion (Misc queries) 2 March 6th 08 07:21 PM
Hide And Un-hide Excel Toolbars Jim333[_4_] Excel Programming 3 July 2nd 05 08:00 PM
How do I hide a worksheet in Excel and use a password to un-hide . Dchung Excel Discussion (Misc queries) 3 December 2nd 04 06:24 AM


All times are GMT +1. The time now is 08:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"