![]() |
#7
|
|||
|
|||
![]()
Cela ne me dérange pas, ça m'occupe en ces temps de confinement.
Voici une nouvelle version complétée : la sortie se fait dans un fichier texte qui s'enregistre dans la racine du disque C. Bien entendu, la terrifiante malédiction a été exorcisée, du moins je l'espère. Pour une sortie sur Excel, c'est bien sûr faisable, mais je n'en sais pas assez. Code:
Sub Essai() Dim Trouvé As String, ListeTrouvés As String Dim Prefixes As Variant, Prefixe As Variant Dim Total As Long 'pour sortie dans un fichier texte Dim SortieFichier As Integer ListeTrouvés = " " Prefixes = Array("PE-", "JEB-", "HEL-") For Each Prefixe In Prefixes With ActiveDocument.Content.Find .ClearFormatting .MatchWildcards = True .Text = Prefixe & "[0-9]{1,}" .Forward = True .Execute Do While .Found Trouvé = .Parent.Text If InStr(1, ListeTrouvés, Trouvé & " ") = 0 Then ListeTrouvés = ListeTrouvés & Trouvé & " " Total = Total + 1 End If .Execute Loop End With Next Prefixe ListeTrouvés = Trim(ListeTrouvés) ListeTrouvés = Replace(ListeTrouvés, " ", vbCrLf) ListeTrouvés = ListeTrouvés & vbCrLf & "Total = " & CStr(Total) 'Sortie des résultats dans le fichier texte SortieFichier = FreeFile Open "c:\SortieFichier.txt" For Output As #SortieFichier Print #SortieFichier, ListeTrouvés Close #SortieFichier End Sub Last edited by jpl; 12-04-2020 at 08:02 AM. Reason: Corrections mineures |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Excel Function To Count All Strings In Range | Pluviophile | Excel | 1 | 09-21-2020 06:22 PM |
Calculate recurring instances between cell count - using trigger - URGENT HELP | sfarad | Excel Programming | 2 | 07-07-2018 07:59 AM |
Count Duplicate Values without a specific Unique Value | Brittni | Excel | 1 | 02-01-2017 06:22 PM |
![]() |
caeiro01 | Excel | 1 | 10-25-2015 02:34 AM |
![]() |
vthomeschoolmom | Excel | 2 | 07-25-2013 06:17 AM |