VBA write in a cell if the adjacent cell contains
Solved
Cocopsl
-
Cocopsl -
Cocopsl -
Bonjour,
I would like to create a VBA code that allows me on a specific sheet (I have about ten sheets) to write "PAPA" in a cell of column P if in the left cell on the same line (column O) there is "MAMAN", and so on for each row.
Despite several tests, it does not work.
Thank you for your help.
I would like to create a VBA code that allows me on a specific sheet (I have about ten sheets) to write "PAPA" in a cell of column P if in the left cell on the same line (column O) there is "MAMAN", and so on for each row.
Despite several tests, it does not work.
Thank you for your help.
4 answers
-
Hello,
How do you trigger this macro? By modifying the cell on the left? Or with a button to launch it?
Then... you mentioned you've tried... very well... show us what you've done, and someone will certainly be able to help you correct your code.
NB: to post code on the forum you will need to use code tags.
Explanations (to read ENTIRELY!) available here: https://codes-sources.commentcamarche.net/faq/11288-poster-un-extrait-de-code
NB²: You can also provide us with an example file by uploading it, for instance, on cijoint
https://www.commentcamarche.net/faq/29493-utiliser-cjoint-pour-heberger-des-fichiers
--
.
Best regards,
Jordane -
Hello,
I will trigger it with a button.
The code I tested came from online research and does not apparently fit my needs.
If it is essential, I will provide it. -
Hello,
Here is the macro I wrote (certainly too simple):
Sub Macro1()
Range("O5:P30").Select
If Range("O") = "Accueil " > 0 Then
cel.Offset(1, 1).Value = " 1_ Accueil"
End If
End Sub
I want that in my column O when there is Accueil in a cell, the word "1_Accueil" gets placed in the adjacent cell.
Thank you for your help.
Cocopsl-
Well... first of all, I had indicated that: to post code on the forum, you must use the code tags.
Explanations (to be read IN FULL!) available here: https://codes-sources.commentcamarche.net/faq/11288-les-balises-de-code
Then, you need to LOOP through each cell in your column "o"
for exampleFor i = 1 To 100 If Cells(i, 15).Value = "Accueil" Then Cells(i, 16).Value = "1_ Accueil" End If Next
Note: this will only work if your cells in column O contain ONLY the word "Accueil"
-
-