VBA: Copy string based on given key matching upto five characters in output sheet.

azov5

New Member
Joined
Dec 27, 2018
Messages
40
I am a novice and looking for a VBA code to copy all sentences of matching string based on the given keys that match up to five characters in the output sheet (as below). My actual data is a few thousand rows long and is in the sheet named "string". My key data is a few hundred and is in the next sheet named output.



HTML:
Excel 2010AB1sl notext21A Theapple and ornage got ID &*(. graps are fine but they are not sweet. 2graps are better. What about ange*l1 of jordan.


The colo of triology is fine. +++colony is named after him. When aJOHN2ofswiss said this ?32A Theapple and ornage got ID &*(. graps are fine but they are not sweet. 2graps are better. What about ange*l1 of jordan.
The colo of triology is fine. +++colony is named after him.When aJOHN2ofswiss said this ?43A Theapple and ornage got ID &*(. graps are fine but they are not sweet. 2graps are better. What about ange*l1 of jordan.
The colo of triology is fine. +++colony is named after him. When aJOHN2ofswiss said this ?[CENTER][COLOR=#161120][B]string[/B][/COLOR][/CENTER]






Excel 2010AB1keyoutput2apple1 &*(       orangeA Theapple and ornage got ID &*(.3orange* graps1graps are fine but they are not sweet. 2graps are better. What about ange*l1 of jordan.4#colony21 triologyThe colo of triology is fine. +++colony is named after him.5*john21+When aJOHN2ofswiss said this ?6*joh17*joh28*joh39*joh410*joh511*joh612*joh713*joh814*joh915*joh1016*joh1117*joh1218*joh1319*joh1420*joh1521*joh1622*joh17[CENTER][COLOR=#161120][B]output[/B][/COLOR][/CENTER]
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Excel 2010
AB
A Theapple and ornage got ID &*(. graps are fine but they are not sweet. 2graps are better. What about ange*l1 of jordan.






The colo of triology is fine. +++colony is named after him. When aJOHN2ofswiss said this ?
A Theapple and ornage got ID &*(.
graps are fine but they are not sweet. 2graps are better. What about ange*l1 of jordan.


The colo of triology is fine. +++colony is named after him.
When aJOHN2ofswiss said this ?
A Theapple and ornage got ID &*(.
graps are fine but they are not sweet. 2graps are better. What about ange*l1 of jordan.


The colo of triology is fine. +++colony is named after him. When aJOHN2ofswiss said this ?

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: center"]sl no[/TD]
[TD="align: center"]text[/TD]

[TD="align: center"]2[/TD]
[TD="align: center"]1[/TD]

[TD="align: center"]3[/TD]
[TD="align: center"]2[/TD]

[TD="align: center"]4[/TD]
[TD="align: center"]3[/TD]

</tbody>
string












Excel 2010
AB
apple1 &*( orangeA Theapple and ornage got ID &*(.
orange* graps1graps are fine but they are not sweet. 2graps are better. What about ange*l1 of jordan.
#colony21 triologyThe colo of triology is fine. +++colony is named after him.
*john21+When aJOHN2ofswiss said this ?
*joh1
*joh2
*joh3
*joh4
*joh5
*joh6
*joh7
*joh8
*joh9
*joh10
*joh11
*joh12
*joh13
*joh14
*joh15
*joh16
*joh17

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] , align: center"]key[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] , align: center"]output[/TD]

[TD="align: center"]2[/TD]

[TD="align: center"]3[/TD]

[TD="align: center"]4[/TD]

[TD="align: center"]5[/TD]

[TD="align: center"]6[/TD]

[TD="align: right"][/TD]

[TD="align: center"]7[/TD]

[TD="align: right"][/TD]

[TD="align: center"]8[/TD]

[TD="align: right"][/TD]

[TD="align: center"]9[/TD]

[TD="align: right"][/TD]

[TD="align: center"]10[/TD]

[TD="align: right"][/TD]

[TD="align: center"]11[/TD]

[TD="align: right"][/TD]

[TD="align: center"]12[/TD]

[TD="align: right"][/TD]

[TD="align: center"]13[/TD]

[TD="align: right"][/TD]

[TD="align: center"]14[/TD]

[TD="align: right"][/TD]

[TD="align: center"]15[/TD]

[TD="align: right"][/TD]

[TD="align: center"]16[/TD]

[TD="align: right"][/TD]

[TD="align: center"]17[/TD]

[TD="align: right"][/TD]

[TD="align: center"]18[/TD]

[TD="align: right"][/TD]

[TD="align: center"]19[/TD]

[TD="align: right"][/TD]

[TD="align: center"]20[/TD]

[TD="align: right"][/TD]

[TD="align: center"]21[/TD]

[TD="align: right"][/TD]

[TD="align: center"]22[/TD]

[TD="align: right"][/TD]

</tbody>
output
 
Upvote 0
Believe me, For the expert it's easy. So I request their help. Gaps will be ignored.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top