Thema Datum  Von Nutzer Rating
Antwort
23.11.2015 15:25:01 henry
NotSolved
Blau string in string
24.11.2015 09:41:50 Gast64994
NotSolved
24.11.2015 12:36:26 henry
NotSolved
24.11.2015 13:25:14 Gast11532
NotSolved
24.11.2015 14:10:52 Henry
NotSolved
24.11.2015 14:32:22 Gast14133
NotSolved
24.11.2015 14:48:48 Henry
NotSolved
24.11.2015 15:08:20 Gast11220
Solved
24.11.2015 17:41:04 Henry
NotSolved
24.11.2015 18:55:37 Gast31698
NotSolved

Ansicht des Beitrags:
Von:
Gast64994
Datum:
24.11.2015 09:41:50
Views:
737
Rating: Antwort:
  Ja
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

 


Ihre Antwort
  • 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: Name: Email:



  • 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
NotSolved
Blau string in string
24.11.2015 09:41:50 Gast64994
NotSolved
24.11.2015 12:36:26 henry
NotSolved
24.11.2015 13:25:14 Gast11532
NotSolved
24.11.2015 14:10:52 Henry
NotSolved
24.11.2015 14:32:22 Gast14133
NotSolved
24.11.2015 14:48:48 Henry
NotSolved
24.11.2015 15:08:20 Gast11220
Solved
24.11.2015 17:41:04 Henry
NotSolved
24.11.2015 18:55:37 Gast31698
NotSolved