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.
March 31st, 2010 at 6:09 pm
cause no one likes you
References :
March 31st, 2010 at 6:32 pm
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 :
March 31st, 2010 at 6:39 pm
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 :
March 31st, 2010 at 7:15 pm
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 :