Consulting

Results 1 to 2 of 2

Thread: Sequence Function

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Nov 2016
    Location
    Hyderabad
    Posts
    1
    Location

    Question Sequence Function

    Hi All,

    I'm trying a function to get sequence between 2 values. Below given example for better understand.

    1st Value = A1245
    2nd Value = A1257

    When I give above values in 'AddNum' function. It should give 'A1245,A1246,A1247' as result.

    Below given vba code wrote by myself and i requesting you, please help on this.


    Public x As Double
    Function AddNum(Val1 As Variant, Val2 As Variant)
    If Val1 = "" Or Val2 = "" Then
    Exit Function
    Else
    x = -(Right(Val1, 4) - Right(Val2, 4))
    End If
        Dim myary As Variant
    ReDim myary(x) As Variant
        For y = LBound(myary) To UBound(myary)
    Z = Right(Val1, 4) + y
    myary(y) = Left(Val1, 2) & Z
    ActiveCell.Offset(0, y + 1).Value = myary(y)
    Next y
        End Function
    Last edited by Aussiebear; 11-24-2016 at 07:09 AM. Reason: Added code tags

Posting Permissions

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