Thema
|
Datum
|
Von Nutzer
|
Rating
|
Antwort
|
|
23.11.2015 15:25:01 |
henry |
|
|
string in string |
24.11.2015 09:41:50 |
Gast64994 |
|
|
|
24.11.2015 12:36:26 |
henry |
|
|
|
24.11.2015 13:25:14 |
Gast11532 |
|
|
|
24.11.2015 14:10:52 |
Henry |
|
|
|
24.11.2015 14:32:22 |
Gast14133 |
|
|
|
24.11.2015 14:48:48 |
Henry |
|
|
|
24.11.2015 15:08:20 |
Gast11220 |
|
|
|
24.11.2015 17:41:04 |
Henry |
|
|
|
24.11.2015 18:55:37 |
Gast31698 |
|
|
Von:
Gast64994 |
Datum:
24.11.2015 09:41:50 |
Views:
737 |
Rating:
|
Antwort:
|
Thema:
string in string |
Hallo Henry!
The code below should work. I suppose the letters can be capital or small. Because I don't know from where you get the string you must adapt this. And you must also adapt the kind how to save the searched string.
Sub stringsearch()
Dim stext As String 'the string in which you search
Dim result As Variant 'the result of seach
Dim member As Variant 'the members of the search if it are more than one
Dim found As Boolean ' if you found a string
Dim Regex As Object
found = False
stext = 'here you must adapt either the string or where he is from, if you use the code as a function I suppose stext comes as argument, then delete this row
Set Regex = CreateObject("Vbscript.Regexp")
With Regex
.Pattern = "\d[a-zA-Z]{4}\d{4}" 'this stand for digit - 4 letters (small or capital) and 4 digits
.IgnoreCase = False
.Global = True ' if you found a result it will look for further hits
If .test(stext) Then found = True ' you found a seached string
Set result = .Execute(stext) 'starts the search
End With
Set Regex = Nothing
If found = True Then ' you found a string
For Each member In result
'place here all you want to do with the found string f.e. save
Next member
Else
' you found nothing and can send a message or do anything else
End If
Set result = Nothing
End Sub
So I hope this works at your system.
Goodbye
Matthias
|
- Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
- Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
- Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
- Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
- Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei
Antworten auf Ihren Beitrag zu benachrichtigen
Bitte geben Sie ein aussagekräftiges Thema an.
Bitte geben Sie eine gültige Email Adresse ein!
- Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
- Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
- Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
- Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
- Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei
Antworten auf Ihren Beitrag zu benachrichtigen
Thema
|
Datum
|
Von Nutzer
|
Rating
|
Antwort
|
|
23.11.2015 15:25:01 |
henry |
|
|
string in string |
24.11.2015 09:41:50 |
Gast64994 |
|
|
|
24.11.2015 12:36:26 |
henry |
|
|
|
24.11.2015 13:25:14 |
Gast11532 |
|
|
|
24.11.2015 14:10:52 |
Henry |
|
|
|
24.11.2015 14:32:22 |
Gast14133 |
|
|
|
24.11.2015 14:48:48 |
Henry |
|
|
|
24.11.2015 15:08:20 |
Gast11220 |
|
|
|
24.11.2015 17:41:04 |
Henry |
|
|
|
24.11.2015 18:55:37 |
Gast31698 |
|
|