Results 1 to 7 of 7

Loop in my macro doesn't seem to be running; however, it compiles fine...

Threaded View

  1. #1
    Registered User
    Join Date
    01-24-2006
    Posts
    8

    Question Loop in my macro doesn't seem to be running; however, it compiles fine...

    I have a loop in my code which compiles fine; however, it doesn't seem to be running (or doing anything?) . The loop is supposed to check the values of Column C in each row, If the value is different than the row below it, then it draws a line along the bottom of all those cells. The rest of my macro runs perfectly fine; however, The loop doesn't appear to do anything. Nothing gets highlighted. I added a line right after j = i + 1 to see if the loop even was running which was ThisWorkbook.Worksheets("Sheet1").Cells(i, "F").Value = 5. None of column F's cell's in Sheet 1 had value 5. There was no value in them whatsoever. This leads me to believe my loop isn't doing anything; however, I'm at a loss as to why. The code is as follows with comments in blue:

    Dim i As Integer 'These are initialized at the start of the macro
    Dim j As Integer

    '***Miscelaneous Macro Code that executes perfectly***

    'Start of Loop that doesn't seem to be running
    For i = 2 To 1000 'run loop a maximum of 1000 iterations
    j = i + 1 'j is 1 more than i so that j can be used to check the next row
    If ThisWorkbook.Worksheets("Sheet1").Cells(j, "C").Value <> "" Then 'check to see If Column C in the row after row(i) isn't empty, if False then exit the loop
    If ThisWorkbook.Worksheets("Sheet1").Cells(i, "C").Value <> ThisWorkbook.Worksheets("Sheet1").Cells(j, "C").Value Then 'check to see if row(i) column C and row(j) column C have different values, if true then row(i) needs to get formatted with a line along the bottom of all row(i)'s cells
    With Rows("i:i").Borders(xlEdgeBottom) 'Create a line along the bottom of all of row(i)'s cells
    .LineStyle = xlContinuous
    .Weight = xlMedium
    .ColorIndex = xlAutomatic
    End With
    End If
    End If
    Next i

    '***More Miscelaneous Macro code that executes perfectly***
    Last edited by Goobies; 01-31-2006 at 04:22 AM.

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