Results 1 to 9 of 9

Thread: Generalized Series Expansions (e.g. AB5-AB9 becomes AB5, AB6, AB7, AB8, AB9)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    14
    @Rick

    I tested only with your offered strings:

    1,5,9-12,20-18
    1 5 9-12 20-15
    1,5 9-12, 20 - 15
    AB8-AB12
    CD3 - CD7 K4, P2-P5 JM8 - JM3
    ABCD1-9
    XYZ3 - 7

    This doesn't error out on my system however.

    Code:
    Sub tst()
        MsgBox F_expand("a9 - 4 x4,m9 r7 b4 - b8,c4-1")
    End Sub
    Code:
    Function F_expand(c00)
      sn = Split(Replace(Replace(Replace(Trim(c00), " -", "-"), "- ", "-"), ",", " "))
      
      For j = 0 To UBound(sn)
        If InStr(sn(j), "-") Then
           c01 = ""
           c02 = ""
           If Val(sn(j)) = 0 Then c01 = Left(sn(j), InStr(sn(j), "-") - Len(Format(Val(StrReverse(Left(sn(j), InStr(sn(j), "-")))))))
           sp = Split(Replace(sn(j), c01, ""), "-")
            
           If Val(sp(0)) > Val(sp(1)) Then c02 = Val(sp(0)) + Val(sp(1)) & "-"
            sn(j) = c01 & Join(Evaluate("transpose(" & c02 & "row(" & sp(0) & ":" & sp(1) & "))"), "," & c01)
        End If
      Next
      
      F_expand = Join(sn, ",")
    End Function
    Last edited by snb; 01-03-2014 at 01:30 AM.

Similar Threads

  1. Convert Series into Range with specified count
    By ayazgreat in forum Excel Help
    Replies: 3
    Last Post: 11-09-2013, 01:41 PM
  2. Formula To Search The Last Occurance Of A Number Series
    By mahmoud-lee in forum Excel Help
    Replies: 2
    Last Post: 10-25-2013, 03:03 AM
  3. Convert Series into Range.
    By ayazgreat in forum Excel Help
    Replies: 13
    Last Post: 03-26-2012, 08:49 PM
  4. Color Chart Series VBA
    By Admin in forum Download Center
    Replies: 0
    Last Post: 04-29-2011, 11:26 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
  •