Hello everyone,
In column "A", all my cells end with "M" for Male and "F" for Female.
In column "J", All cells start with "Male" when the last character in column "A" is an "M", and start with "Female" when the last character in column "A" is "F".
Still in column "J", each cell begins with "Male or "Female" followed by several information on the subject which is in column "A".
Information: It is not always easy to determine the exact sex especially when my birds are young, hence the need to change the sex in column "A" and column "J" thereafter.
When the sex is definitely determined, then, I start by selecting the cell(s) in column "A" of the subjects whose sex I want to change via a button, By clicking on this button, if the subject is mentioned as a Male ( So, the column cell "A" ends with "M") and I want to change the sex, so we replace the "M" with "F", likewise, if the subject is mentioned as a Female (so , the cell in column "A" ends with an "F"), then, we replace the "F" by "M".
The code below makes it possible to implement what I have just described.
This is where I would like your help, namely:
I also want to change the sex in column "J", replacing the word "Male" or "Female" at the beginning of the cells in column "J" depending of course on the sex changed in column "A".
My table is quite large, that's why I allow myself to ask you for a code that can make the changes quickly.
I hope that I am clear in my explanations, if not, I remain at your disposal for other additional information.
Thanks in advance for your contributions.
Here is the working table in reduced format.
EDIT:
I forgot to add a small detail concerning the cells in column "J", if the cells in column "J" do not begin with the word "Male" or "Female" (The words "Male" or "Female" are absent ), then we add the word adapted to the sex of the subjects who are in the cells in column "A".
Good programming.
In column "A", all my cells end with "M" for Male and "F" for Female.
In column "J", All cells start with "Male" when the last character in column "A" is an "M", and start with "Female" when the last character in column "A" is "F".
Still in column "J", each cell begins with "Male or "Female" followed by several information on the subject which is in column "A".
Information: It is not always easy to determine the exact sex especially when my birds are young, hence the need to change the sex in column "A" and column "J" thereafter.
When the sex is definitely determined, then, I start by selecting the cell(s) in column "A" of the subjects whose sex I want to change via a button, By clicking on this button, if the subject is mentioned as a Male ( So, the column cell "A" ends with "M") and I want to change the sex, so we replace the "M" with "F", likewise, if the subject is mentioned as a Female (so , the cell in column "A" ends with an "F"), then, we replace the "F" by "M".
The code below makes it possible to implement what I have just described.
VBA Code:
Sub Changer_Sexe()
'''select one or more cells and then replace "M" with "F" and "F" with "M"
Application.ScreenUpdating = False
For Each c In Selection
If Right(c.Value, 1) = "M" Then
c.Value = Left(c.Value, Len(c.Value) - 1) & "F"
ElseIf Right(c.Value, 1) = "F" Then
c.Value = Left(c.Value, Len(c.Value) - 1) & "M"
End If 'fin de test pour changement de sexe
Next c
Application.ScreenUpdating = True
End Sub
This is where I would like your help, namely:
I also want to change the sex in column "J", replacing the word "Male" or "Female" at the beginning of the cells in column "J" depending of course on the sex changed in column "A".
My table is quite large, that's why I allow myself to ask you for a code that can make the changes quickly.
I hope that I am clear in my explanations, if not, I remain at your disposal for other additional information.
Thanks in advance for your contributions.
Here is the working table in reduced format.
Classeur1.xlsm | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | |||
1 | Jeune | Père | Mère | Eleveur | Age | Volière | Cage | Né(e) | Tours | Information | Elevage | ||
2 | AETYTT-093/2012 M | AED27-093/2012 M | 27-093/2012 M | Gérard Claude | 10a 11m 28j | 2B | 16 | 41068 | 4T | Mâle Tt Jaune (Belle Posture) | |||
3 | AE27-094/2012 M | AE27-094/2012 M | AET27-094/2012 M | Gérard Claude | 10a 11m 28j | 2B | 16 | 41068 | 4T | Male avec tâche au dos | X | ||
4 | AEY27-100/2012 F | AER27-100/2012 F | E27-100/2012 F | Gérard Claude | 10a 11m 26j | 2B | 13 | 41070 | 4T | Femelle Toute Jaune (très belle) | |||
5 | GAE27-059/2013 F | AEGG27-059/2013 F | AE27-059/2013 F | Gérard Claude | 10a 1m 11j | 3H | 13 | 41389 | 4T | Femelle toute jaune (Magnifique) | X | ||
6 | AE27-060/2013 M | AE27-060/2013 M | AE27-060/2013 M | Gérard Claude | 10a 0m 31j | 5H | 19 | 41399 | 5T | Mâle Panaché | |||
7 | AUE27-087/2013 F | AE27-087/2013 F | AE-087/2013 F | Gérard Claude | 10a 0m 18j | 5H | 22 | 41412 | 4T | Femelle tâche à la tête | X | ||
8 | AE27-011/2019 F | AEJ27-011/2019 F | RG27-011/2019 F | Gérard Claude | 4a 1m 14j | 4H | 11 | 43577 | 5T | Femelle Tâche au dos | X | ||
9 | AE27-012/2019 F | AE27-012/2019 F | HT-012/2019 F | Gérard Claude | 4a 1m 14j | 5H | 11 | 43577 | 5T | Femelle Tte Jaune | X | ||
10 | AE27-013/2019 M | AE27-013/2019 M | AE27-013/2019 M | Gérard Claude | 4a 1m 14j | 4H | 1 | 43577 | 4T | Mâle (très beau) | X | ||
11 | AE27-014/2019 F | AEG27-014/2019 F | A-014/2019 F | Gérard Claude | 4a 1m 16j | 4H | 2 | 43575 | 4T | Femelle Belle Taille | |||
12 | AEGYT-015/2019 M | G-015/2019 M | TT7-015/2019 M | Gérard Claude | 4a 1m 17j | 4H | 6 | 43574 | 4T | Mâle beau Chant | X | ||
Feuil1 |
EDIT:
I forgot to add a small detail concerning the cells in column "J", if the cells in column "J" do not begin with the word "Male" or "Female" (The words "Male" or "Female" are absent ), then we add the word adapted to the sex of the subjects who are in the cells in column "A".
Good programming.
Last edited by a moderator: