+ Reply to Thread
Results 1 to 11 of 11

Thread: Hide whole row when cel C3 is 0 (zero)

  1. #1
    blommerse@saz.nl
    Guest

    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. #2
    Harald Staff
    Guest

    Re: 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

    <blommerse@saz.nl> skrev i melding
    news:1150095682.955357.169390@c74g2000cwc.googlegroups.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. #3
    Berry
    Guest

    Re: 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. #4
    Berry
    Guest

    Re: 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. #5
    Executor
    Guest

    Re: 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. #6
    Berry
    Guest

    Re: 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. #7
    Harald Staff
    Guest

    Re: 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" <blommerse@saz.nl> skrev i melding
    news:1150098249.748426.149230@j55g2000cwa.googlegroups.com...
    >
    > Hi Herald,
    >
    > That didn't worked. Nothing happened when I copied the code!
    >
    > Do you need more info??
    > Greets
    >




  8. #8
    Berry
    Guest

    Re: Hide whole row when cel C3 is 0 (zero)


    Thanks. This one work fine. Enjoy you coffee.

    Cheers


  9. #9
    Harald Staff
    Guest

    Re: Hide whole row when cel C3 is 0 (zero)

    "Berry" <blommerse@saz.nl> skrev i melding
    news:1150106212.013477.95790@f6g2000cwb.googlegroups.com...
    >
    > Thanks. This one work fine. Enjoy you coffee.
    >
    > Cheers


    Good. Cheers.
    Best wishes Harald



  10. #10
    Executor
    Guest

    Re: 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. #11
    Berry
    Guest

    Re: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0