LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Visual Basic code help needed

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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
repeating code in visual basic tobypitblado Excel Discussion (Misc queries) 4 September 17th 08 11:55 AM
Visual Basic code Pickle Excel Discussion (Misc queries) 1 September 4th 08 03:35 PM
I need a visual basic code....please Rhonda Excel Discussion (Misc queries) 1 March 5th 07 01:18 PM
Control box help - visual basic code jontait Excel Programming 2 March 4th 04 03:20 PM
Visual Basic Code Robert Couchman Excel Programming 2 February 2nd 04 03:10 PM


All times are GMT +1. The time now is 09:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"