Why is my Macro skipping the If statement completely?

March 31, 2010 - 1:02 pm

I have a VB Macro to compare data in an Excel spreadsheet and if the totals match up then it needs to delete the specified rows. It matches certain values and deletes but in some instances it skips the entire if statement. If i go through it step by step i can see it doing that. The values are majority decimal and i have converted any text from the cells into Double.

Please help me urgently!!!!!!!!!!!!!!

Unless we have the source code how we will solve it.

If you want please send the workbook to me (jn1717@gmail.com). I will try to solve.

4 Responses to “Why is my Macro skipping the If statement completely?”

  1. DeepNinesLover Says:

    cause no one likes you
    References :

  2. TaZ Says:

    Unless we have the source code how we will solve it.

    If you want please send the workbook to me (jn1717@gmail.com). I will try to solve.
    References :

  3. Cozmosis Says:

    I’m guessing that you are checking a column of cells from top to bottom. If you delete a row, the rows below the deleted row move up to take it’s place. The cell that just moved up will not be checked because your macro will move on to the next cell down

    Example:
    You delete cell A5 and then want to check cell A6 if it should be deleted. Before you check cell A6, A6 will have moved up to take the place of the deleted A5. So you never really check what was A6 because it is now A5.

    The easiest way around this is to check your cells starting from bottom up (the last cell in the column to the top.)
    References :

  4. garbo7441 Says:

    If you are using a ‘For i = 1 to Lastrow’ type loop to delete rows meeting the ‘IF’ criteria, try changing your ‘For’ to:

    For i = LastRow to 1 Step -1
    References :

Leave a Reply