Results 1 to 3 of 3

Thread: [RESOLVED]excel vba question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2001
    Posts
    103

    [RESOLVED]excel vba question

    i have an excelsheet with 1 column of data
    column 1 holds numbers from 1 to 100

    I have to check if all numbers from 1 to 100 are in the column

    i.e.:
    1
    2
    3
    5
    6
    7

    number 4 is missing. i have to add a row between 3 and 5 and fill in 4
    it is also possible that more numbers are missing:
    1
    4
    5
    6
    Last edited by newbiekea; Jan 4th, 2006 at 09:26 AM.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: excel vba question

    Yuo may try doing some thing similar to following but KIM it's only a quick sample:
    VB Code:
    1. Private Sub Worksheet_Activate()
    2. Dim i%, sValue$, iNum%
    3.  
    4.     sValue = "-1000"
    5.     iNum = -999
    6.    
    7.     Do While IsNumeric(Trim$(sValue)) = True
    8.         i = i + 1
    9.         iNum = CInt(Sheet1.Cells(i, "A"))
    10.         sValue = Sheet1.Cells(i + 1, "A")
    11.         If Trim$(sValue) = "" Then Exit Sub
    12.        
    13.         If Abs(CInt(sValue) - iNum) <> 1 Then
    14.             Sheet1.Cells(i + 1, "A") = iNum + 1
    15.         End If
    16.     Loop
    17.  
    18. End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2001
    Posts
    103

    Re: [RESOLVED]excel vba question

    ok, thx, this was almost everything i needed, great!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width