Visual Basic code help needed
I tried running this on its own and it didn't do anything
(although it didn't crash).
Running it with the other code present, I get a type
mismatch error on the following line:
V = Evaluate("Row(" & prev + 1 & ":" & C - 1 & ")")
Try running the code with the following numbers in column
A and let me know if you get the same problem:
6097
6098
6099
60*06
60*26
60*28
6100
6101
6102
-----Original Message-----
y would be the rows
change the column "A" to what ever column you have the
numbers in.
this will remove any * in the numbers between A:6000 to
A:6299 the way it is
setup now.
I would run this before you run your other code
For y = 6000 To 6299
For x = 1 To Len(Range("A" & y))
If Mid(Range("A" & y), x, 1) = "*" Then
Range("A" & y) = Left(Range("A" & y), x - 1)
& Right(Range("A"
& y), Len(Range("A" & y)) - x)
End If
Next x
Next y
wrote in message
...
Thanks - but how would I incorporate this into the
already
existing code below? Note that the code has a specific
range of numbers between 6000-6299. When I paste a
batch
of numbers in and run the macro, it'll spit back the
numbers that aren't on the list.
-Rick
-----Original Message-----
If you want to remove the * use this code
For y = 1 To 10
For x = 1 To Len(Range("A" & y))
If Mid(Range("A" & y), x, 1) = "*" Then
Range("A" & y) = Left(Range("A" & y), x -
1)
& Right(Range("A" &
y), Len(Range("A" & y)) - x)
End If
Next x
Next y
Michael Tomasura
"Rick" wrote in
message
...
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
.
.
|