R
Rick
I use the following code to determine which numbers are
missing from a column of data I paste in. Some of the
numbers on the list I enter have a * character in front of
them, which crashes the routine below unless I go into the
original list and manually delete all the numbers with a
*.
Can someone help me figure out a bit of code that I could
add to the routine below that would allow the * numbers to
be ignored from the list? I also don't want the * numbers
to be counted in the missing number list.
For example:
My original list of numbers is the following:
6000
6002
6*003
6*004
6005
6007
6*008
6009
and so forth...
After I paste this list in...the resulting missing numbers
list would give me:
6001
6003
6004
6006
6008
....
Unfortunately this doesn't work until I manually remove
the * numbers. Any help with the additional code needed
would be terrific.
-Rick
--------------------
Sub DisplayMissing_150()
Dim C As Range, V As Variant
Dim prev&, k&, n&
k = 1
prev = 5999 ' one less than beginning, here 6000
For Each C In Intersect(Range("A:A"),
ActiveSheet.UsedRange)
If C > prev + 1 Then ' some numbers left
V = Evaluate("Row(" & prev + 1 & ":" & C - 1 & ")")
n = C - (prev + 1)
Cells(k, "C").Resize(n, 1) = V
k = k + n
End If
prev = C
Next C
' do the last ones, aka from the highest to 6299
If prev < 6299 Then
V = Evaluate("Row(" & prev + 1 & ":6299)")
n = 6299 - prev
Cells(k, "C").Resize(n, 1) = V
End If
End Sub
missing from a column of data I paste in. Some of the
numbers on the list I enter have a * character in front of
them, which crashes the routine below unless I go into the
original list and manually delete all the numbers with a
*.
Can someone help me figure out a bit of code that I could
add to the routine below that would allow the * numbers to
be ignored from the list? I also don't want the * numbers
to be counted in the missing number list.
For example:
My original list of numbers is the following:
6000
6002
6*003
6*004
6005
6007
6*008
6009
and so forth...
After I paste this list in...the resulting missing numbers
list would give me:
6001
6003
6004
6006
6008
....
Unfortunately this doesn't work until I manually remove
the * numbers. Any help with the additional code needed
would be terrific.
-Rick
--------------------
Sub DisplayMissing_150()
Dim C As Range, V As Variant
Dim prev&, k&, n&
k = 1
prev = 5999 ' one less than beginning, here 6000
For Each C In Intersect(Range("A:A"),
ActiveSheet.UsedRange)
If C > prev + 1 Then ' some numbers left
V = Evaluate("Row(" & prev + 1 & ":" & C - 1 & ")")
n = C - (prev + 1)
Cells(k, "C").Resize(n, 1) = V
k = k + n
End If
prev = C
Next C
' do the last ones, aka from the highest to 6299
If prev < 6299 Then
V = Evaluate("Row(" & prev + 1 & ":6299)")
n = 6299 - prev
Cells(k, "C").Resize(n, 1) = V
End If
End Sub