[vba excel] macro to hide row

Vince7338 Posted messages 1 Status Member -  
 Jacquou -
Hello everyone,

I have a problem with a VBA macro in Excel (I specify that I don't know much!!! I just know how to use macros but not create them!!!)
So, I have a table of the type:
''''''''''''''''''''''A''''''''''''''''''''''''''''''''''''''B'''''''''''''''''''''''''''''C''''''''''''''''''''''''''''''''''''''D
1
2
3
4
5'''''''''Equipments'''''''''''''Domains'''''''''''''''Impact '''''''''''''''''''Action to take
6''''''''Compactor''''''''''''''''''''Air''''''''''''''''''''Dust''''''''''Do analysis by lab
7'''''''''''''''Tour
8'''''Welding station
9'''''''''''''''Oven''''''''''''''''''''''''''''''''Air'''''''''''''''''''''''Smoke''''''''''''''Do analysis by lab

I would like to have a button (macro) to obtain the following table format to facilitate printing because my table is very large:

''''''''''''''''''''''A''''''''''''''''''''''''''''''''''''''B'''''''''''''''''''''''''''''C''''''''''''''''''''''''''''''''''''''D
1
2
3
4
5'''''''''Equipments'''''''''''''Domains'''''''''''''''Impact '''''''''''''''''''Action to take
6''''''''Compactor''''''''''''''''''''Air''''''''''''''''''''Dust''''''''''Do analysis by lab
9'''''''''''''''Oven''''''''''''''''''''''''''''''''Air'''''''''''''''''''''''Smoke''''''''''''''Do analysis by lab

So the condition is: if there is no impact (empty cell in column C), the entire row should be hidden. Then, I would need a second button to make the hidden rows reappear. I want the first 4 rows to remain because they contain my company's logo + document update date, etc.

Thank you in advance

Vince
Configuration: Windows XP Firefox 2.0.0.5

4 answers

  1. TORTUE85 Posted messages 12 Status Member 17
     
    Alright, I'm going to try to give you a solution
    ------
    TO HIDE
    ----------

    Sub hide()
    Range("B1:B7").Select 'B1:B7 corresponds to the range of cells you want to check
    For Each o In Selection
    If o.Value = "" Then
    o.EntireRow.Hidden = True
    End If
    Next

    End Sub
    -----------------------------------------------------

    TO SHOW YOUR CELLS
    -----------
    Sub unhide()

    Range("B1:B7").Select
    Selection.EntireRow.Hidden = False
    End Sub

    ------------------------------------------------

    And then you go to Excel...Tools/Macro/Run a macro..
    Magic magic you discover two macros (Hide and Unhide)

    Then you can add buttons to your Excel sheet and when you click on them, it runs the macros.

    DISPLAY / TOOLBAR / FORM

    You select the button
    Place it on your sheet and select the right macro to assign..

    BYE....Looking forward to it
    19
    1. 3ziwez Posted messages 7 Status Member
       
      Hello forum, hello thread,
      Your turtles85 code works perfectly, the only problem is that the rows are not completely empty, I have formulas in them, so Excel does not consider them as empty.
      How can I work around this issue???!!!

      Thank you
      Azel
      0
    2. m
       
      Hello,

      Thank you for this code. It was helpful. However, I am encountering a problem: when I put this code three times in a row with different ranges but always on the same sheet, it indicates: compilation error, ambiguous name detected: hide.

      Could you please help me

      Thank you in advance
      0
    3. Jacquou
       
      Thank you, great and simple ideas!
      0