Hello everyone,
I have a code which should normally replace certain characters (in column "K") with other characters, but it is impossible to make it work, where is the problem?
Unless I'm mistaken, the correct result is in column "N".
Thank you for your propositions.
I have a code which should normally replace certain characters (in column "K") with other characters, but it is impossible to make it work, where is the problem?
Unless I'm mistaken, the correct result is in column "N".
Thank you for your propositions.
VBA Code:
Sub remplacer_Chaines()
Dim ws As Worksheet
Dim arrReplace As Variant
Dim strReplacement As String
Dim i As Long
Set ws = ThisWorkbook.Sheets("Parents")
arrReplace = Array(, "elevé", "Hty27", "hty27", "Hwa96", "hwa96", "cage")
For i = LBound(arrReplace) To UBound(arrReplace)
Select Case arrReplace(i)
Case "elevé"
strReplacement = "Elevé"
Case "Hty27", "hty27"
strReplacement = "HTY27"
Case "Hwa96", "hwa96"
strReplacement = "HWA96"
Case "cage"
strReplacement = "Cage"
End Select
ws.Columns("K").Replace What:=arrReplace(i), Replacement:=strReplacement, LookAt:=xlWhole, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Next i
End Sub
Code_Test.xlsm | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | |||
1 | Jeune+N46A1:N44 | Père | Mère | Eleveur | Âge | Volière | Cage | Né(e) | Tours | Couleur | Elevage | Consanguinité | ancêtre principale | Résultat | ||
2 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-017/23 cage 12 | * | * | Elevé/HTY27-017/23 Cage 12 | ||
3 | * | * | * | * | * | * | * | * | * | * | elevé/Hty27-017/23 cage 12X | * | * | Elevé/HTY27-017/23 Cage 12X | ||
4 | * | * | * | * | * | * | * | * | * | * | elevé/Hty27-017/23 Cage 12 X | * | * | Elevé/HTY27-017/23 Cage 12 X | ||
5 | * | * | * | * | * | * | * | * | * | * | elevé/Hty27-017/23 cage 12 | * | * | Elevé/HTY27-017/23 Cage 12 | ||
6 | * | * | * | * | * | * | * | * | * | * | elevé/Hty27-023/23 cage 8 | * | * | Elevé/HTY27-023/23 Cage 8 | ||
7 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-023/23 cage 9 | * | * | Elevé/HTY27-023/23 Cage 9 | ||
8 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-023/23 cage 10 | * | * | Elevé/HTY27-023/23 Cage 10 | ||
9 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-023/23 Cage 11 | * | * | Elevé/HTY27-023/23 Cage 11 | ||
10 | * | * | * | * | * | * | * | * | * | * | elevé/hwa96-045/22 cage 13 | * | * | Elevé/HWA96-045/22 Cage 13 | ||
11 | * | * | * | * | * | * | * | * | * | * | elevé/Hty27-015/23 cage 11 | * | * | Elevé/HTY27-015/23 Cage 11 | ||
12 | * | * | * | * | * | * | * | * | * | * | elevé/Hwa96-045/22 cage 14 | * | * | Elevé/HWA96-045/22 Cage 14 | ||
13 | * | * | * | * | * | * | * | * | * | * | elevé/Hty27-019/23 Cage 6 | * | * | Elevé/HTY27-019/23 Cage 6 | ||
14 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-015/23 cage 11 | * | * | Elevé/HTY27-015/23 Cage 11 | ||
15 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-015/23 cage 11 | * | * | Elevé/HTY27-015/23 Cage 11 | ||
16 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-015/23 cage 11 | * | * | Elevé/HTY27-015/23 Cage 11 | ||
17 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-038/22 Cage 10 X | * | * | Elevé/HTY27-038/22 Cage 10 X | ||
18 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-038/22 cage 10 | * | * | Elevé/HTY27-038/22 Cage 10 | ||
19 | * | * | * | * | * | * | * | * | * | * | elevé/Hty27-010/23 cage 5 | * | * | Elevé/HTY27-010/23 Cage 5 | ||
20 | * | * | * | * | * | * | * | * | * | * | elevé/Hwa96-034/21 cage 2 | * | * | Elevé/HWA96-034/21 Cage 2 | ||
21 | * | * | * | * | * | * | * | * | * | * | elevé/Hty27-038/22 cage 10 | * | * | Elevé/HTY27-038/22 Cage 10 | ||
22 | * | * | * | * | * | * | * | * | * | * | elevé/Hwa96-010/21 cage 9 | * | * | Elevé/HWA96-010/21 Cage 9 | ||
23 | * | * | * | * | * | * | * | * | * | * | elevé/hwa96-010/21 Cage 9 | * | * | Elevé/HWA96-010/21 Cage 9 | ||
24 | * | * | * | * | * | * | * | * | * | * | elevé/hwa96-010/21 cage 9 | * | * | Elevé/HWA96-010/21 Cage 9 | ||
25 | * | * | * | * | * | * | * | * | * | * | elevé/hwa96-034/21 cage 2 | * | * | Elevé/HWA96-034/21 Cage 2 | ||
26 | * | * | * | * | * | * | * | * | * | * | elevé/hwa96-010/21 cage 9 | * | * | Elevé/HWA96-010/21 Cage 9 | ||
27 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-019/23 cage 6 | * | * | Elevé/HTY27-019/23 Cage 6 | ||
28 | * | * | * | * | * | * | * | * | * | * | elevé/Hty27-010/23 cage 5 | * | * | Elevé/HTY27-010/23 Cage 5 | ||
29 | * | * | * | * | * | * | * | * | * | * | elevé/Hwa96-02723 cage 14 | * | * | Elevé/HWA96-02723 Cage 14 | ||
30 | * | * | * | * | * | * | * | * | * | * | elevé/Hty27-010/23 cage 5 | * | * | Elevé/HTY27-010/23 Cage 5 | ||
31 | * | * | * | * | * | * | * | * | * | * | elevé/Hwa96-010/21 cage 9 | * | * | Elevé/HWA96-010/21 Cage 9 | ||
32 | * | * | * | * | * | * | * | * | * | * | elevé/Hwa96-027/23 cage 14 | * | * | Elevé/HWA96-027/23 Cage 14 | ||
33 | * | * | * | * | * | * | * | * | * | * | elevé/Hwa96-027/23 cage 14 | * | * | Elevé/HWA96-027/23 Cage 14 | ||
34 | * | * | * | * | * | * | * | * | * | * | elevé/Hty27-026/22 cage 1 | * | * | Elevé/HTY27-026/22 Cage 1 | ||
35 | * | * | * | * | * | * | * | * | * | * | elevé/Hty27-026/22 cage 1 | * | * | Elevé/HTY27-026/22 Cage 1 | ||
36 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-026/22 cage 1 | * | * | Elevé/HTY27-026/22 Cage 1 | ||
37 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-026/22 cage 1 | * | * | Elevé/HTY27-026/22 Cage 1 | ||
38 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-020/23 cage 7 | * | * | Elevé/HTY27-020/23 Cage 7 | ||
39 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-020/23 cage 7 | * | * | Elevé/HTY27-020/23 Cage 7 | ||
40 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-020/23 cage 7 | * | * | Elevé/HTY27-020/23 Cage 7 | ||
41 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-020/23 cage 7 | * | * | Elevé/HTY27-020/23 Cage 7 | ||
42 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-037/22 cage 3 | * | * | Elevé/HTY27-037/22 Cage 3 | ||
43 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-037/22 cage 3 | * | * | Elevé/HTY27-037/22 Cage 3 | ||
44 | * | * | * | * | * | * | * | * | * | * | elevé/hty27-037/22 cage 3 | * | * | Elevé/HTY27-037/22 Cage 3 | ||
Parents |