Results 1 to 3 of 3

Thread: Missing Numbers Range VBA

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    2
    Rep Power
    0

    Missing Numbers Range VBA

    Rick you also posted the following code on msdn:

    Code:
    Function MissingNumbers(Rng As Range) As String
       Dim X As Long, MaxNum As Long
       MaxNum = WorksheetFunction.Max(Rng)
       ReDim Nums(1 To MaxNum)
       For X = 1 To MaxNum
         If Rng.Find(X, LookAt:=xlWhole) Is Nothing Then
           MissingNumbers = MissingNumbers & ", " & X
         End If
       Next
       MissingNumbers = Mid(MissingNumbers, 3)
     End Function
    -----

    This function was very helpful. Can you add a couple of lines that builds a string that contains the addresses of the cells within the range, or is it not possible for a UFD?
    Please advise.

    Thanks

    Rhett
    Last edited by Admin; 10-26-2013 at 11:32 AM.

  2. #2
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    13
    I am confused as to what you want. That code produces a comma separated list of the number that do not appear in the range of cells passed into it. I do not understand what addresses you want to see... the numbers are not there so there are no addresses for them. Can you clarify what you want please (providing a before and after example would be useful)?

  3. #3
    Junior Member
    Join Date
    Oct 2013
    Posts
    2
    Rep Power
    0
    As I understand it, the MissingNumbers(A1:A15) function that you developed generates a string of missing numbers in the range where some of the cells are blank. I'm trying to use a similar function that contains a list of cells that could potentially hold any of those missing numbers. Using your range (A1:A15), it contained up to 15 numbers, the smallest was 7, the largest 22, with several blank cells. My range is (D4 to F6), which has 9 cells, some of the cells have a known number (1-9), no duplicates for example 4,7,8, 9. Most of the cells are empty, and can contain any of the missing numbers 1,2,3,4,6,8. I want to get the addresses of the blank cells in the range (D4 to F6). For example 1,2,3,4,6,8; what is the address for X. I realize that X cannot contain 4,7,8, 9.

    X
    8 9 4
    7


    Hope this clarifies question.

    Thank you,

    Rhett

Similar Threads

  1. Replies: 10
    Last Post: 08-29-2013, 08:20 PM
  2. Replies: 2
    Last Post: 07-18-2013, 03:34 AM
  3. VBA Looping Input Range and Output Range
    By Whitley in forum Excel Help
    Replies: 7
    Last Post: 04-25-2013, 09:02 PM
  4. Replies: 4
    Last Post: 04-05-2013, 12:08 PM
  5. VBA Function To Extract Decimal Numbers
    By PcMax in forum Excel Help
    Replies: 7
    Last Post: 11-19-2011, 09:42 PM

Posting Permissions

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