Results 1 to 6 of 6

Create A Looped If Structure

Threaded View

nevi Create A Looped If Structure 02-27-2011, 01:57 PM
davesexcel Re: Create A Looped If... 02-27-2011, 02:23 PM
nevi Re: Create A Looped If... 02-27-2011, 02:37 PM
nevi Re: Create A Looped If... 02-27-2011, 02:39 PM
davesexcel Re: Create A Looped If... 02-27-2011, 03:23 PM
nevi Re: Create A Looped If... 02-27-2011, 03:40 PM
  1. #1
    Forum Contributor
    Join Date
    04-06-2006
    Posts
    131

    Talking Create A Looped If Structure

    Hey There!

    I think what I am trying to do here is fairly simple, but for the life of me I can not remember how to write a Loop statement. I'm pretty basic when it comes to VB and Macros and am trying to teach myself as I go...

    In a nut shell, I need a macro that will follow this logic:
    * Add the values in K22 and M22 together
    * If this value is 0, hide the row
    * If it is not 0, move on to the next row

    If needs to loop through this logic, checking every row from 22 to 1021, hiding all the rows where the value is 0 and leaving the rows that are not 0 displayed.

    I came up with this:
    If Range("K22").Value = "0" Or Range("M22").Value = "0" Then
            Rows("22").Select
            Selection.EntireRow.Hidden = True
    End If
    If Range("K23").Value = "0" Or Range("M23").Value = 0 Then
            Rows("23").Select
            Selection.EntireRow.Hidden = True
    End If
    If Range("K24").Value = "0" Or Range("M24").Value = 0 Then
            Rows("24").Select
            Selection.EntireRow.Hidden = True
    End If
    If Range("K25").Value = "0" Or Range("M25").Value = 0 Then
    ...
    so on and so forth...

    I don't particularily want to type this out 1,000 times though, and I seem to remeber that a Loop structure could do this for me, but I just don't recall how to do it.

    Thanx in adance for your help!!
    Last edited by nevi; 02-27-2011 at 03:19 PM.

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