numbers extraction

AlanY

Well-known Member
Joined
Oct 30, 2014
Messages
3,944
Office Version
365, 2019, 2016
Platform
Windows
this is the question posted by another member in "Questions in Other Languages"
https://www.mrexcel.com/forum/questions-other-languages/1099110-extract-tail-tail-combination.html

that I'd translated here

the last digit of any pairs of numbers in A:F matched the last digit in G, merged the said pairs' last digit into H and so on, e.g.

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th><th>G</th><th>H</th><th>I</th><th>J</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">10</td><td style="text-align: right;;">101</td><td style="text-align: right;;">102</td><td style="text-align: right;;">103</td><td style="text-align: right;;">104</td><td style="text-align: right;;">105</td><td style="text-align: right;;">106</td><td style="text-align: right;;">103</td><td style="text-align: right;;">12</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">11</td><td style="text-align: right;;">101</td><td style="text-align: right;;">102</td><td style="text-align: right;;">103</td><td style="text-align: right;;">104</td><td style="text-align: right;;">105</td><td style="text-align: right;;">106</td><td style="text-align: right;;">108</td><td style="text-align: right;;">26</td><td style="text-align: right;;">35</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">12</td><td style="text-align: right;;">101</td><td style="text-align: right;;">102</td><td style="text-align: right;;">103</td><td style="text-align: right;;">104</td><td style="text-align: right;;">105</td><td style="text-align: right;;">106</td><td style="text-align: right;;">107</td><td style="text-align: right;;">16</td><td style="text-align: right;;">25</td><td style="text-align: right;;">34</td></tr></tbody></table><p style="width:4.8em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet4</p><br /><br />
 
Last edited:

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Try this:-
Data assumed to start "A1"
This code also Posted in Other thread.
Code:
[COLOR="Navy"]Sub[/COLOR] MG28May05
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, Num [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac1 [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac2 [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Col [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range("A1", Range("A" & Rows.Count).End(xlUp))

[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
Col = 6
Num = Right(Dn.Offset(, 6), 1)
[COLOR="Navy"]For[/COLOR] Ac1 = 0 To 5
    [COLOR="Navy"]For[/COLOR] Ac2 = Ac1 + 1 To 5
        [COLOR="Navy"]If[/COLOR] Val(Right(Dn.Offset(, Ac1), 1) + Val(Right(Dn.Offset(, Ac2), 1))) = Num [COLOR="Navy"]Then[/COLOR]
            Col = Col + 1
            Dn.Offset(, Col) = Right(Dn.Offset(, Ac1), 1) & Right(Dn.Offset(, Ac2), 1)
        [COLOR="Navy"]End[/COLOR] If
    [COLOR="Navy"]Next[/COLOR] Ac2
[COLOR="Navy"]Next[/COLOR] Ac1
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Last edited:

AlanY

Well-known Member
Joined
Oct 30, 2014
Messages
3,944
Office Version
365, 2019, 2016
Platform
Windows
excellent!!
thanks
 

Forum statistics

Threads
1,081,681
Messages
5,360,521
Members
400,590
Latest member
hiicinc

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top