Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Printing selective rows

  1. #1
    Guest

    Default

    I have a spreadsheet with inventory data in it and I want to selectively hide rows. Essentially, I do not want rows to print that have zero in the quantity column (let's use column 1 in this example).

    My thought was to create a macro that would go to A1, test it for zero, hide the row if it is zero, and go down to the next row. It should end when it comes to the word "end" in a cell.

    Problem is: I don't know how to write Excel macros. Any ideas? Thanks.

  2. #2
    MrExcel MVP Barrie Davidson's Avatar
    Join Date
    Feb 2002
    Location
    Winnipeg
    Posts
    2,330
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    You don't really need to do this via a macro. Why not use data filtering? From the main menu, select Data|Filter|AutoFilter. You can then specify to show non-zero values. If you need any help with this just let me know.

    PS - you should post this question in the "Macro Questions" section since this forum is only for testing. At least that's my understanding
    Barrie Davidson

    "You're only given a little spark of madness. You mustn't lose it." - Robin Williams

  3. #3
    MrExcel MVP Aladin Akyurek's Avatar
    Join Date
    Feb 2002
    Location
    The Hague, NL
    Posts
    84,026
    Post Thanks / Like
    Mentioned
    37 Post(s)
    Tagged
    7 Thread(s)

    Default

    [Y]ou should post this question in the "Macro Questions" section since this forum is only for testing. At least that's my understanding
    I can hardly blame the OP: Cross-postings & wrong choice of category in which to post will be our biggest problem with the new board, I'm afraid, and endless space consuming remarks pointing out these 'mistakes'. Darn it, I already produced at least 3 posts regarding this issue!



    Aladin

    [ This Message was edited by: Aladin Akyurek on 2002-02-16 11:42 ]

  4. #4
    New Member
    Join Date
    Feb 2002
    Location
    SAC, CA
    Posts
    35
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    See if this will help you...

    Dim Cell As Range
    Dim blnCellHasData As Boolean

    For Each Cell In Range("A1:R1")
    If Cell.Value = 0 Then
    Rows("1:1").EntireRow.Hidden = True
    Else
    blnCellHasData = True
    End If
    Next
    If blnCellHasData = False Then
    Rows("1:1").EntireRow.Hidden = True
    Else
    Rows("1:1").EntireRow.Hidden = False
    End If

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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