+ Reply to Thread
Results 1 to 42 of 42

Find the strings of only the last digits of the numbers in the 5 sectors, please!

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Find the strings of only the last digits of the numbers in the 5 sectors, please!
    link=http://www.mediafire.com/file/eb42j93sg4n5s4c/pasta_string_hoje.xlsx

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    So what do you want the result to be?

    54 or eb42j93sg4n5s4c
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Try this for starters:-
    Your data starts "A3",Results start "W3".
    Sub MG15Apr39
    Dim Rng As Range, Dn As Range, n As Long, num As Long
    Dim nstr1 As String, nstr2 As String, nstr3 As String, nstr4 As String, nstr5 As String
    Set Rng = Range(Range("A3"), Range("A" & Rows.Count).End(xlUp))
    Application.ScreenUpdating = False
    For Each Dn In Rng
    ReDim BRay(0 To 100) As Boolean
        For n = 1 To 20
            BRay(Dn(, n).Value) = True
        Next n
    
    For n = 1 To UBound(BRay)
        If BRay(n) = True Then
            num = IIf(Len(CStr(n)) = 2, Mid(n, 2), n)
    
            Select Case CStr(BRay(n))
                Case n < 21: nstr1 = nstr1 & IIf(nstr1 = "", num, ", " & num)
                Case n < 41: nstr2 = nstr2 & IIf(nstr2 = "", num, ", " & num)
                Case n < 61: nstr3 = nstr3 & IIf(nstr3 = "", num, ", " & num)
                Case n < 81: nstr4 = nstr4 & IIf(nstr4 = "", num, ", " & num)
                Case Else: nstr5 = nstr5 & IIf(nstr5 = "", num, ", " & num)
            End Select
    End If
    Next n
        Dn.Offset(, 22).Value = nstr1
        Dn.Offset(, 23).Value = nstr2
        Dn.Offset(, 24).Value = nstr3
        Dn.Offset(, 25).Value = nstr4
        Dn.Offset(, 26).Value = nstr5
    
        nstr1 = "": nstr2 = "": nstr3 = "": nstr4 = "": nstr5 = ""
    Next Dn
    Application.ScreenUpdating = True
    End Sub
    Regards Mick

    http://www.dec.org.uk/

  4. #4
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Ok, MIKE! you, have to sort as was in the example = have put the corresponding colors in the draws, my lottery is 100/20
    You have each sector vector the strings, have the option to put new draws the macro go doing as it puts new draws of course
    Can you put the planilia in a link, please?

  5. #5
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Hello,MICK it's not like that, mick
    You have to make each of the 5 colors, only last digit from 0 to 9 the strings
    You have to see the strings for each of the 5 sectors. You have to mark the corresponding color in the draw list

  6. #6
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Try this:-
    NB:- The last Group of numbers has 99 instead of 89 and I've altered the the first "00" to 90
    ONLY LAST DIGIT
    1 2 3 4 5 6 7 8 9 0
    81 82 83 84 85 86 87 88 99 00
    91 92 93 94 95 96 97 98 99 00



    Sub MG15Apr22
    Private Sub CommandButton2_Click()
    Dim Rng As Range, Dn As Range, n As Long, num As Long, W As Long, ac As Long
    Dim RngA As Range, txt As String, Rn As Range, nRng As Range, nStr As String, Hoz As Long
    Dim nstr1 As String, nstr2 As String, nstr3 As String, nstr4 As String, nstr5 As String
    Dim Dic As Object
    Application.ScreenUpdating = False
    Set RngA = Range("V3:AE4,AG3:AP4,AR3:BA4,BC3:BL4,BN3:BW4")
    Set Dic = CreateObject("scripting.dictionary")
    For Each Dn In RngA
        W = IIf(Dn.Value = "00", 100, Dn.Value)
        Set Dic(W) = Dn
    Next
    
    Set Rng = Range(Range("A5"), Range("A" & Rows.Count).End(xlUp))
    Application.ScreenUpdating = False
    For Each Dn In Rng
    ac = 0
    ReDim BRay(0 To 100) As Boolean
        For n = 1 To 20
            W = IIf(Dn(, n) = "00", 100, Dn(, n))
            BRay(W) = True
        Next n
    Dim R As Range
    For n = 1 To UBound(BRay)
        
        If BRay(n) = True Then
            Set R = Cells(Dn.Row, Dic(n).Column)
             R = R & IIf(R.Value = "", "x", ",x")
        End If
    Next n
        For Hoz = 1 To 5
             Set nRng = Cells(Dn.Row, "V").Resize(, 10).Offset(, ac)
                ac = ac + 11
            For Each Rn In nRng
                If Rn.Value <> "" Then
                    txt = Replace(Rn.Value, "x", Cells(2, Rn.Column).Value)
                    nStr = nStr & IIf(nStr = "", txt, ", " & txt)
                End If
            Next Rn
            nRng(nRng.Count).Offset(, 1).Value = nStr: nStr = ""
        Next Hoz
    Next Dn
    Application.ScreenUpdating = True
    End Sub
    Regards Mick

    http://www.dec.org.uk/

  7. #7
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Sorry the corret please is 89 90
    99 00 error = is corret 89 90

  8. #8
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    error =Sub MG15Apr22()
    Private Sub CommandButton2_Click()

  9. #9
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Sub MG15Apr22()
    Private Sub CommandButton2_Click()

  10. #10
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Hello, MICK please can you put the code in the worksheet? When I try to activate, it shows error

  11. #11
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Give this a try

    Sub abc()
     Dim i As Long, ii As Long
     Dim tmp, sMyStrings, sCols
     
     
     sCols = Array(32, 43, 54, 65, 76)
     For i = 5 To Cells(Rows.Count, "a").End(xlUp).Row
        ReDim sMyStrings(4)
        For ii = 1 To 20
            tmp = Application.Evaluate("=MATCH(" & Cells(i, ii).Value & ",3:3,0)")
            If VBA.IsNumeric(tmp) Then
                Cells(i, tmp).Value = IIf(Cells(i, tmp).Value = "", "x", Cells(i, tmp).Value & ",x")
            Else
                tmp = Application.Evaluate("=MATCH(" & Cells(i, ii).Value & ",4:4,0)")
                Cells(i, tmp).Value = IIf(Cells(i, tmp).Value = "", "x", Cells(i, tmp).Value & ",x")
            End If
            Select Case tmp
                Case Is <= 32
                    sMyStrings(0) = IIf(sMyStrings(0) = "", Right(Cells(i, ii).Value, 1), sMyStrings(0) & "," & Right(Cells(i, ii).Value, 1))
                    Cells(i, ii).Interior.Color = 65535        'Yellow
                Case Is <= 43
                    sMyStrings(1) = IIf(sMyStrings(1) = "", Right(Cells(i, ii).Value, 1), sMyStrings(1) & "," & Right(Cells(i, ii).Value, 1))
                    Cells(i, ii).Interior.Color = 11892015     'Blue
                Case Is <= 54
                    sMyStrings(2) = IIf(sMyStrings(2) = "", Right(Cells(i, ii).Value, 1), sMyStrings(2) & "," & Right(Cells(i, ii).Value, 1))
                    Cells(i, ii).Interior.Color = 5287936      'Green
                Case Is <= 65
                    sMyStrings(3) = IIf(sMyStrings(3) = "", Right(Cells(i, ii).Value, 1), sMyStrings(3) & "," & Right(Cells(i, ii).Value, 1))
                    Cells(i, ii).Interior.Color = 255          'Red
                Case Is <= 76
                    sMyStrings(4) = IIf(sMyStrings(4) = "", Right(Cells(i, ii).Value, 1), sMyStrings(4) & "," & Right(Cells(i, ii).Value, 1))
                    Cells(i, ii).Interior.Color = 13285804     'Gray
            End Select
        Next
        For ii = LBound(sCols) To UBound(sCols)
            Cells(i, sCols(ii)) = sMyStrings(ii)
        Next
        DoEvents
     Next
     MsgBox "Finished"
    End Sub

  12. #12
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    excel 2014 Windows 7

  13. #13
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Did you change 89 and 90?

  14. #14
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    error=Else
    tmp = Application.Evaluate("=MATCH(" & Cells(i, ii).Value & ",4:4,0)")
    Cells(i, tmp).Value = IIf(Cells(i, tmp).Value = "", "x", Cells(i, tmp).Value & ",x")
    End If

  15. #15
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    YES,MIKE you have to make this correction in the sector,
    Logically, 89.90 is correct! Sorry

  16. #16
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Also I'm guessing you'll want the strings sorted

    Sub abc()
     Dim i As Long, ii As Long
     Dim tmp, sMyStrings() As String, sCols
     
     'Application.ScreenUpdating = False
     sCols = Array(32, 43, 54, 65, 76)
     For i = 5 To Cells(Rows.Count, "a").End(xlUp).Row
        ReDim sMyStrings(4)
        For ii = 1 To 20
            tmp = Application.Evaluate("=MATCH(" & Cells(i, ii).Value & ",3:3,0)")
            If VBA.IsNumeric(tmp) Then
                Cells(i, tmp).Value = IIf(Cells(i, tmp).Value = "", "x", Cells(i, tmp).Value & ",x")
            Else
                tmp = Application.Evaluate("=MATCH(" & Cells(i, ii).Value & ",4:4,0)")
                If VBA.IsNumeric(tmp) Then
                    Cells(i, tmp).Value = IIf(Cells(i, tmp).Value = "", "x", Cells(i, tmp).Value & ",x")
                End If
            End If
            If VBA.IsNumeric(tmp) Then
                Select Case tmp
                    Case Is <= 32
                        sMyStrings(0) = IIf(sMyStrings(0) = "", Right(Cells(i, ii).Value, 1), sMyStrings(0) & "," & Right(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = 65535        'Yellow
                    Case Is <= 43
                        sMyStrings(1) = IIf(sMyStrings(1) = "", Right(Cells(i, ii).Value, 1), sMyStrings(1) & "," & Right(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = 11892015     'Blue
                    Case Is <= 54
                        sMyStrings(2) = IIf(sMyStrings(2) = "", Right(Cells(i, ii).Value, 1), sMyStrings(2) & "," & Right(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = 5287936      'Green
                    Case Is <= 65
                        sMyStrings(3) = IIf(sMyStrings(3) = "", Right(Cells(i, ii).Value, 1), sMyStrings(3) & "," & Right(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = 255          'Red
                    Case Is <= 76
                        sMyStrings(4) = IIf(sMyStrings(4) = "", Right(Cells(i, ii).Value, 1), sMyStrings(4) & "," & Right(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = 13285804     'Gray
                End Select
            End If
        Next
        For ii = LBound(sCols) To UBound(sCols)
            Cells(i, sCols(ii)).Value = BubbleSrt(sMyStrings(ii), True)
        Next
        DoEvents
     Next
     'Application.ScreenUpdating = True
     MsgBox "Finished"
    End Sub
    
    Public Function BubbleSrt(StringIO As String, Ascending As Boolean)
    Dim ArrayIn As Variant
    Dim SrtTemp As Variant
    Dim i As Long
    Dim j As Long
        
        ArrayIn = Split(StringIO, ",")
        
        If Ascending = True Then
            For i = LBound(ArrayIn) To UBound(ArrayIn)
                 For j = i + 1 To UBound(ArrayIn)
                     If ArrayIn(i) > ArrayIn(j) Then
                         SrtTemp = ArrayIn(j)
                         ArrayIn(j) = ArrayIn(i)
                         ArrayIn(i) = SrtTemp
                     End If
                 Next j
             Next i
        Else
            For i = LBound(ArrayIn) To UBound(ArrayIn)
                 For j = i + 1 To UBound(ArrayIn)
                     If ArrayIn(i) < ArrayIn(j) Then
                         SrtTemp = ArrayIn(j)
                         ArrayIn(j) = ArrayIn(i)
                         ArrayIn(i) = SrtTemp
                     End If
                 Next j
             Next i
        End If
        BubbleSrt = Join(ArrayIn, ",")
    End Function

  17. #17
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Try your returned file:-
    See sheet2.
    Check results that are showing, then remove and run code again to test.
    Attached Files Attached Files

  18. #18
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    When I change those on your workbook it works fine for me
    Attached Files Attached Files

  19. #19
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Hello, mike de best, great, very good job, spectacular
    It looks great.
    Mike you did the 5 lines, now I'm going to link the 5 columns,
    Is to do everything equal, just changed the sectors wait until I put the link
    Use the same macro for the 5 columns or sectors

  20. #20
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Okay, gonna grab something to eat and walk the dog. Be back shortly

  21. #21
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!


  22. #22
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Hello, mike is now only first digit only
    Use the same formula or previous macro, so it changes
    Now the scan is from the first digit ok.
    Do the same, but with the first digit of the number
    Option to go putting new draws of course

  23. #23
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551
    Quote Originally Posted by jorel View Post
    Hello, mike is now only first digit only
    Use the same formula or previous macro, so it changes
    Now the scan is from the first digit ok.
    Do the same, but with the first digit of the number
    Option to go putting new draws of course
    You should be able to do this, find in the code where it has Right(.....,1) change to Left(.....,1)

  24. #24
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    But changed the letters in the new worksheet, changed the reference, is the colors? please

  25. #25
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Change out this section of the code

                Select Case tmp
                    Case Is <= 32
                        sMyStrings(0) = IIf(sMyStrings(0) = "", Left(Cells(i, ii).Value, 1), sMyStrings(0) & "," & Left(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = Cells(3, tmp).Interior.Color  '65535        'Yellow
                    Case Is <= 43
                        sMyStrings(1) = IIf(sMyStrings(1) = "", Left(Cells(i, ii).Value, 1), sMyStrings(1) & "," & Left(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = Cells(3, tmp).Interior.Color  '11892015     'Blue
                    Case Is <= 54
                        sMyStrings(2) = IIf(sMyStrings(2) = "", Left(Cells(i, ii).Value, 1), sMyStrings(2) & "," & Left(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = Cells(3, tmp).Interior.Color  '5287936      'Green
                    Case Is <= 65
                        sMyStrings(3) = IIf(sMyStrings(3) = "", Left(Cells(i, ii).Value, 1), sMyStrings(3) & "," & Left(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = Cells(3, tmp).Interior.Color  '255          'Red
                    Case Is <= 76
                        sMyStrings(4) = IIf(sMyStrings(4) = "", Left(Cells(i, ii).Value, 1), sMyStrings(4) & "," & Left(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = Cells(3, tmp).Interior.Color  '13285804     'Gray
                End Select

    Sub abc()
     Dim i As Long, ii As Long
     Dim tmp, sMyStrings() As String, sCols
     
     'Application.ScreenUpdating = False
     sCols = Array(32, 43, 54, 65, 76)
     For i = 5 To Cells(Rows.Count, "a").End(xlUp).Row
        ReDim sMyStrings(4)
        For ii = 1 To 20
            tmp = Application.Evaluate("=MATCH(" & Cells(i, ii).Value & ",3:3,0)")
            If VBA.IsNumeric(tmp) Then
                Cells(i, tmp).Value = IIf(Cells(i, tmp).Value = "", "x", Cells(i, tmp).Value & ",x")
            Else
                tmp = Application.Evaluate("=MATCH(" & Cells(i, ii).Value & ",4:4,0)")
                If VBA.IsNumeric(tmp) Then
                    Cells(i, tmp).Value = IIf(Cells(i, tmp).Value = "", "x", Cells(i, tmp).Value & ",x")
                End If
            End If
            If VBA.IsNumeric(tmp) Then
                Select Case tmp
                    Case Is <= 32
                        sMyStrings(0) = IIf(sMyStrings(0) = "", Left(Cells(i, ii).Value, 1), sMyStrings(0) & "," & Left(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = Cells(3, tmp).Interior.Color  '65535        'Yellow
                    Case Is <= 43
                        sMyStrings(1) = IIf(sMyStrings(1) = "", Left(Cells(i, ii).Value, 1), sMyStrings(1) & "," & Left(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = Cells(3, tmp).Interior.Color  '11892015     'Blue
                    Case Is <= 54
                        sMyStrings(2) = IIf(sMyStrings(2) = "", Left(Cells(i, ii).Value, 1), sMyStrings(2) & "," & Left(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = Cells(3, tmp).Interior.Color  '5287936      'Green
                    Case Is <= 65
                        sMyStrings(3) = IIf(sMyStrings(3) = "", Left(Cells(i, ii).Value, 1), sMyStrings(3) & "," & Left(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = Cells(3, tmp).Interior.Color  '255          'Red
                    Case Is <= 76
                        sMyStrings(4) = IIf(sMyStrings(4) = "", Left(Cells(i, ii).Value, 1), sMyStrings(4) & "," & Left(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = Cells(3, tmp).Interior.Color  '13285804     'Gray
                End Select
            End If
        Next
        For ii = LBound(sCols) To UBound(sCols)
            Cells(i, sCols(ii)).Value = BubbleSrt(sMyStrings(ii), True)
        Next
        DoEvents
     Next
     'Application.ScreenUpdating = True
     MsgBox "Finished"
    End Sub
    Last edited by mike7952; 04-15-2017 at 07:26 PM. Reason: Fixed code

  26. #26
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    error=or ii = LBound(sCols) To UBound(sCols)
    Cells(i, sCols(ii)).Value = BubbleSrt(sMyStrings(ii), True)

  27. #27
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Must be doing something on your end, works fine for me.

  28. #28
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Function not defined compilation error

  29. #29
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    I didn't post the function with the last code, thinking you would have left the function in the module.

    Public Function BubbleSrt(StringIO As String, Ascending As Boolean)
    Dim ArrayIn As Variant
    Dim SrtTemp As Variant
    Dim i As Long
    Dim j As Long
        
        ArrayIn = Split(StringIO, ",")
        
        If Ascending = True Then
            For i = LBound(ArrayIn) To UBound(ArrayIn)
                 For j = i + 1 To UBound(ArrayIn)
                     If ArrayIn(i) > ArrayIn(j) Then
                         SrtTemp = ArrayIn(j)
                         ArrayIn(j) = ArrayIn(i)
                         ArrayIn(i) = SrtTemp
                     End If
                 Next j
             Next i
        Else
            For i = LBound(ArrayIn) To UBound(ArrayIn)
                 For j = i + 1 To UBound(ArrayIn)
                     If ArrayIn(i) < ArrayIn(j) Then
                         SrtTemp = ArrayIn(j)
                         ArrayIn(j) = ArrayIn(i)
                         ArrayIn(i) = SrtTemp
                     End If
                 Next j
             Next i
        End If
        BubbleSrt = Join(ArrayIn, ",")
    End Function

  30. #30
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Mike can not ride, hiker does not have much talent in excel
    I will not be able to ride for years.

  31. #31
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Lol, So have you got it working now, or you still needing a ride?

  32. #32
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!


  33. #33
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Link doesn't drive. You still needing a solution?

  34. #34
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    But it's another spreadsheet with groups for the columns! Another planilia with the same conditions only changed the groups

  35. #35
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    This don't work? Color of cell is self adjusting

    Sub abc()
     Dim i As Long, ii As Long
     Dim tmp, sMyStrings() As String, sCols
     
     'Application.ScreenUpdating = False
     sCols = Array(32, 43, 54, 65, 76)
     For i = 5 To Cells(Rows.Count, "a").End(xlUp).Row
        ReDim sMyStrings(4)
        For ii = 1 To 20
            tmp = Application.Evaluate("=MATCH(" & Cells(i, ii).Value & ",3:3,0)")
            If VBA.IsNumeric(tmp) Then
                Cells(i, tmp).Value = IIf(Cells(i, tmp).Value = "", "x", Cells(i, tmp).Value & ",x")
            Else
                tmp = Application.Evaluate("=MATCH(" & Cells(i, ii).Value & ",4:4,0)")
                If VBA.IsNumeric(tmp) Then
                    Cells(i, tmp).Value = IIf(Cells(i, tmp).Value = "", "x", Cells(i, tmp).Value & ",x")
                End If
            End If
            If VBA.IsNumeric(tmp) Then
                Select Case tmp
                    Case Is <= 32
                        sMyStrings(0) = IIf(sMyStrings(0) = "", Left(Cells(i, ii).Value, 1), sMyStrings(0) & "," & Left(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = Cells(3, tmp).Interior.Color  '65535        'Yellow
                    Case Is <= 43
                        sMyStrings(1) = IIf(sMyStrings(1) = "", Left(Cells(i, ii).Value, 1), sMyStrings(1) & "," & Left(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = Cells(3, tmp).Interior.Color  '11892015     'Blue
                    Case Is <= 54
                        sMyStrings(2) = IIf(sMyStrings(2) = "", Left(Cells(i, ii).Value, 1), sMyStrings(2) & "," & Left(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = Cells(3, tmp).Interior.Color  '5287936      'Green
                    Case Is <= 65
                        sMyStrings(3) = IIf(sMyStrings(3) = "", Left(Cells(i, ii).Value, 1), sMyStrings(3) & "," & Left(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = Cells(3, tmp).Interior.Color  '255          'Red
                    Case Is <= 76
                        sMyStrings(4) = IIf(sMyStrings(4) = "", Left(Cells(i, ii).Value, 1), sMyStrings(4) & "," & Left(Cells(i, ii).Value, 1))
                        Cells(i, ii).Interior.Color = Cells(3, tmp).Interior.Color  '13285804     'Gray
                End Select
            End If
        Next
        For ii = LBound(sCols) To UBound(sCols)
            Cells(i, sCols(ii)).Value = BubbleSrt(sMyStrings(ii), True)
        Next
        DoEvents
     Next
     'Application.ScreenUpdating = True
     MsgBox "Finished"
    End Sub
    Public Function BubbleSrt(StringIO As String, Ascending As Boolean)
    Dim ArrayIn As Variant
    Dim SrtTemp As Variant
    Dim i As Long
    Dim j As Long
        
        ArrayIn = Split(StringIO, ",")
        
        If Ascending = True Then
            For i = LBound(ArrayIn) To UBound(ArrayIn)
                 For j = i + 1 To UBound(ArrayIn)
                     If ArrayIn(i) > ArrayIn(j) Then
                         SrtTemp = ArrayIn(j)
                         ArrayIn(j) = ArrayIn(i)
                         ArrayIn(i) = SrtTemp
                     End If
                 Next j
             Next i
        Else
            For i = LBound(ArrayIn) To UBound(ArrayIn)
                 For j = i + 1 To UBound(ArrayIn)
                     If ArrayIn(i) < ArrayIn(j) Then
                         SrtTemp = ArrayIn(j)
                         ArrayIn(j) = ArrayIn(i)
                         ArrayIn(i) = SrtTemp
                     End If
                 Next j
             Next i
        End If
        BubbleSrt = Join(ArrayIn, ",")
    End Function
    Last edited by mike7952; 04-16-2017 at 07:53 AM.

  36. #36
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    new link=http://www.mediafire.com/file/s25p175day697kq/string%2Cnova_planilia__columm.xlsx

  37. #37
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Code in this link works for me

    Click here

  38. #38
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    new link=http://www.mediafire.com/file/s25p175day697kq/string%2Cnova_planilia__columm.xlsx

  39. #39
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    Click the button. I guess I'm not understanding your request and why the new links?
    Attached Files Attached Files

  40. #40
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    k? Color of cell is self adjusting

  41. #41
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    What's not working now?

  42. #42
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,344

    Re: Find the strings of only the last digits of the numbers in the 5 sectors, please!

    OK man! Mike, great job congratulations, works perfect,
    Mike, you're great at excel, congratulations, thank you,

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Find missing digits when comparing two numbers
    By Karnik in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-25-2017, 03:26 PM
  2. [SOLVED] Compare two numbers to in column and find which digits are missing
    By Karnik in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-16-2017, 10:34 AM
  3. [SOLVED] Combine digits in double digits in 4 numbers without repeating each other
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-14-2014, 08:18 AM
  4. vlookup only the right most 4 digits of the 6 digits sequential numbers
    By tabcm66 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 05-02-2014, 07:33 AM
  5. [SOLVED] Conditional formating loop to find numbers that are within x digits of each other.
    By rjnewsome in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-07-2013, 08:11 AM
  6. Replies: 0
    Last Post: 12-13-2012, 08:15 AM
  7. How to find and extract numbers that may be present in lengthy text strings
    By Langkawi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-15-2007, 03:17 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1