Thanks for your help, but it didn't quite work as i had needed. This is a portion of the data set:
Book1 |
---|
|
---|
| B | C | D | E |
---|
3 | --- | --- | --- | --- |
---|
4 | --- | --- | --- | --- |
---|
5 | --- | --- | --- | --- |
---|
6 | --- | --- | --- | --- |
---|
7 | --- | --- | --- | --- |
---|
8 | 454 | 433 | --- | --- |
---|
9 | 479 | NaN | 442 | 477 |
---|
10 | NaN | 439 | 439 | 478 |
---|
11 | NaN | 449 | 436 | 486 |
---|
12 | 442 | 470 | 439 | 489 |
---|
13 | 461 | 453 | 439 | 479 |
---|
|
---|
This is my macro:
Sub deletedata()
col = ActiveCell.Column
For x = 3 To 500
If Cells(x, col) = "---" Then
Cells(x, col).Select
Selection.Delete Shift:=xlUp
End If
If Cells(x, col) = "NaN" Then
Cells(x, col) = 0
End If
If Cells(x + 1, col) = "NaN" Then
Cells(x + 1, col) = 0
End If
If Abs(Cells(x, col) - Cells(x + 1, col)) > 30 Then
Cells(x, col).Interior.ColorIndex = 36
Cells(x, col).Interior.Pattern = xlSolid
Cells(x + 1, col).Interior.ColorIndex = 36
Cells(x + 1, col).Interior.Pattern = xlSolid
End If
Next x
End Sub
The first IF statement is the one not working. When removed the other three IF's work fine (by first changing any NaN to zero, then highlighting any two sequential cells with a difference of greater than 30). The problem is I need ALL cells in a column with "---" deleted and shifted up BEFORE any of the other IF statements run. Is there a way to have it select ALL the cells with "---" before any of them are deleted, THEN run the other If statements?
thanks again