Home > Software engineering >  To extract the strings, a great god help write a or excel vba code function
To extract the strings, a great god help write a or excel vba code function

Time:09-17

Sd SDS sad sad adsw sda
000154546548;Sd SDS SFGD sad adsw sda; dahhsda ndfd4654815151
SDS SFGD sad adsw sda
99151551515;SDS SFGD sad adsw
9548481515;SFGD sad adsw
4544512185;Sd SDS sad sad adsw sda
000154546548;Sd SDS SFGD sad adsw sda; dahhsda ndfd4654815151
SDS SFGD sad adsw sda
99151551515;SDS SFGD sad adsw
9548481515;SFGD sad adsw
4544512185;Sd SDS sad sad adsw sda
000154546548;Sd SDS SFGD sad adsw sda; dahhsda ndfd4654815151
SDS SFGD sad adsw sda
99151551515;SDS SFGD sad adsw
9548481515;SFGD sad adsw
4544512185;Sd SDS sad sad adsw sda
000154546548;Sd SDS SFGD sad adsw sda; dahhsda ndfd4654815151
SDS SFGD sad adsw sda
99151551515;SDS SFGD sad adsw
9548481515;SFGD sad adsw
4544512185;Sd SDS sad sad adsw sda
000154546548;Sd SDS SFGD sad adsw sda; dahhsda ndfd4654815151
SDS SFGD sad adsw sda
99151551515;SDS SFGD sad adsw
9548481515;SFGD sad adsw
4544512185;Sd SDS sad sad adsw sda
000154546548;Sd SDS SFGD sad adsw sda; dahhsda ndfd4654815151
SDS SFGD sad adsw sda
99151551515;SDS SFGD sad adsw
9548481515;SFGD sad adsw
4544512185;Sd SDS sad sad adsw sda
000154546548;Sd SDS SFGD sad adsw sda; dahhsda ndfd4654815151
SDS SFGD sad adsw sda
99151551515;SDS SFGD sad adsw
9548481515;SFGD sad adsw
4544512185;Sd SDS sad sad adsw sda
000154546548;Sd SDS SFGD sad adsw sda; dahhsda ndfd4654815151
SDS SFGD sad adsw sda
99151551515;SDS SFGD sad adsw
9548481515;SFGD sad adsw
4544512185;Sd SDS sad sad adsw sda
000154546548;Sd SDS SFGD sad adsw sda; dahhsda ndfd4654815151
SDS SFGD sad adsw sda
99151551515;SDS SFGD sad adsw
9548481515;SFGD sad adsw
4544512185;Sd SDS sad sad adsw sda
000154546548;
Everybody is good, above is a line of data, need to extract the final data in a row, such as sd SDS SFGD sad adsw sda; dahhsda ndfd4654815151, extracted need

Is: ndfd4654815151, inside each string, contains seven Spaces, 6 Spaces, five Spaces, four Spaces, three blanks, so please the great god, and writing a generation of

Code or excel function, to extract the strings, thank you,

CodePudding user response:

Give you a piece of code reference, can also be used in VBA, has the same syntax,

 Private Sub Command1_Click () 
Dim arrBuff () As String
Dim strText As String

StrText="sd SDS SFGD sad adsw sda; dahhsda ndfd4654815151"
ArrBuff=Split (strText, "")
'key points: the Split () function to use
'a lot of text, oneself use circulation processing
'if the source string "the end" is likely to take space, then removes white Spaces at the end:
'arrBuff=Split (RTrim $(strText), "")
MsgBox "the last paragraph:" & amp; ArrBuff (UBound (arrBuff ())), and 64
End Sub

CodePudding user response:

 Private Sub Command1_Click () 
Dim strline As String

Open "c: \ test \ test. TXT" For Input As # 1
The Open c: \ test \ "new \ test. TXT" For the Output As # 2
Do Until EOF (1)
The Line Input # 1, strline
Strline=Mid (strline InStrRev (strline, "") + 1)
Print # 2, strline
Loop
Close # 2
Close # 1
End Sub

 000154546548 
Ndfd4654815151
99151551515
9548481515
4544512185
000154546548
Ndfd4654815151
99151551515
9548481515
4544512185
000154546548
Ndfd4654815151
99151551515
9548481515
4544512185
000154546548
Ndfd4654815151
99151551515
9548481515
4544512185
000154546548
Ndfd4654815151
99151551515
9548481515
4544512185
000154546548
Ndfd4654815151
99151551515
9548481515
4544512185
000154546548
Ndfd4654815151
99151551515
9548481515
4544512185
000154546548
Ndfd4654815151
99151551515
9548481515
4544512185
000154546548
Ndfd4654815151
99151551515
9548481515
4544512185
000154546548

CodePudding user response:

Visual his data rather than a text file in excel,

CodePudding user response:

Is the core content is InStrRev function, everything else is floating clouds, in some also just as well,

CodePudding user response:

4th floor talk nonsense, your code is one of the most tedious, use the split () function is king, simple and clear, the line directly to the string separated by a space most array and the set of data in the table below target, the most simple,

CodePudding user response:

reference 5 floor qq_35328269 reply:
4th floor talk nonsense, your code is one of the most tedious, use the split () function is king, simple and clear, the line directly to the string separated by a space most array and the set of data in the table below target, the most simple,
do you know how is the function of the underlying implementation? So, you really are "blind" said,

CodePudding user response:

The split just code quantity is less, consuming resources more actually,

CodePudding user response:

refer to 6th floor of123 response:
Quote: refer to the fifth floor qq_35328269 reply:

4th floor talk nonsense, your code is one of the most tedious, use the split () function is king, simple and clear, the line directly to the string separated by a space most array and the set of data in the table below target, the most simple,
do you know how is the function of the underlying implementation? So, you really are "blind", says

As you say, I'm really not sure slipt function is how to realize, I also did not go to further study,

However,

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • VBA
  • Related