+ Reply to Thread
Results 1 to 2 of 2

Hiding Rows in a VBA macro

  1. #1
    Registered User
    Join Date
    05-15-2006
    Posts
    2

    Hiding Rows in a VBA macro

    Hi,

    I want to set up a looping macro in VBA so that it looks at the first column of the work book and if this is empty, the entire row is hidden.

    I have got the code below - the lopping works just cant get the correct code for hidding the row.

    Sub printpage()

    Dim main As Worksheet
    Dim mrow As Long
    Set main = ThisWorkbook.Worksheets("WORKPLANNER")
    mrow = 8

    Do Until mrow = 352

    If main.Cells(mrow, 1) = "" Then
    main.Cells(mrow, "") = "test"Else
    End If
    mrow = mrow + 1
    Loop
    End Sub


    also when i print a worksheet with a number of hidden rows is there a way for Excel to ignore these completely.


    Thanks

    Steven

  2. #2
    Ardus Petus
    Guest

    Re: Hiding Rows in a VBA macro

    Sub PRINTPAGE()

    Dim MAIN As Worksheet
    Dim MROW As Long
    Set MAIN = ThisWorkbook.Worksheets("WORKPLANNER")

    For MROW = 8 To 352
    If MAIN.Cells(MROW, 1).Value = "\" Then
    MAIN.Rows(MROW).Hidden = True
    End If
    Next MROW

    End Sub

    HTH
    --
    AP

    "sarcher" <[email protected]> a écrit
    dans le message de news:
    [email protected]...
    >
    > Hi,
    >
    > I want to set up a looping macro in VBA so that it looks at the first
    > column of the work book and if this is empty, the entire row is
    > hidden.
    >
    > I have got the code below - the lopping works just cant get the correct
    > code for hidding the row.
    >
    > SUB PRINTPAGE()
    >
    > DIM MAIN AS WORKSHEET
    > DIM MROW AS LONG
    > SET MAIN = THISWORKBOOK.WORKSHEETS(\"WORKPLANNER\")
    > MROW = 8
    >
    > DO UNTIL MROW = 352
    >
    > IF MAIN.CELLS(MROW, 1) = \"\" THEN
    > -MAIN.CELLS(MROW, \"\") = \"TEST\"-ELSE
    > END IF
    > MROW = MROW + 1
    > LOOP
    > END SUB
    >
    > also when i print a worksheet with a number of hidden rows is there a
    > way for Excel to ignore these completely.
    >
    >
    > Thanks
    >
    > Steven
    >
    >
    > --
    > sarcher
    > ------------------------------------------------------------------------
    > sarcher's Profile:
    > http://www.excelforum.com/member.php...o&userid=34457
    > View this thread: http://www.excelforum.com/showthread...hreadid=542123
    >




+ 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.6.0 RC 1