chris6999
XLDnaute Impliqué
Bonjour
Je souhaiterais balayer mon tableau afin de renvoyer dans ma colonne T une valeur définie dans le code à partir de la valeur du dernier caractère de ma colonne B à condition que B soit non vide et T soit vide
ex si B dans B (non vide) dernier caractère de B = 1 alors renvoie la valeur "A" sans la colonne T (si T vide)
J'ai essayé de faire un mix de plusieurs macros trouvées dans les fils mais cela ne semble pas fonctionner :
Sub portefeuille()
Dim cel As Range
For Each cel In Range("B7:B" & Range("B65535").End(xlUp).Row)
If cel <> "" And Cells(cel.Row, 20).Value = "" And Len(Cells(cel.Row, 2)) = 1 Then
Cells(cel.Row, 20) = "a"
End If
If cel <> "" And Cells(cel.Row, 20).Value = "" And Len(Cells(cel.Row, 2)) = 2 Then
Cells(cel.Row, 20) = "B"
End If
If cel <> "" And Cells(cel.Row, 20).Value = "" And Len(Cells(cel.Row, 2)) = 3 Then
Cells(cel.Row, 20) = "C"
End If
If cel <> "" And Cells(cel.Row, 20).Value = "" And Len(Cells(cel.Row, 2)) = 4 Then
Cells(cel.Row, 20) = "D"
End If
If cel <> "" And Cells(cel.Row, 20).Value = "" And Len(Cells(cel.Row, 2)) = 5 Then
Cells(cel.Row, 20) = "E"
End If
'Etc .......
Next
End Sub
Quelqu'un verrait-il où le bas blesse?
Merci d'avance
Cordialement
Je souhaiterais balayer mon tableau afin de renvoyer dans ma colonne T une valeur définie dans le code à partir de la valeur du dernier caractère de ma colonne B à condition que B soit non vide et T soit vide
ex si B dans B (non vide) dernier caractère de B = 1 alors renvoie la valeur "A" sans la colonne T (si T vide)
J'ai essayé de faire un mix de plusieurs macros trouvées dans les fils mais cela ne semble pas fonctionner :
Sub portefeuille()
Dim cel As Range
For Each cel In Range("B7:B" & Range("B65535").End(xlUp).Row)
If cel <> "" And Cells(cel.Row, 20).Value = "" And Len(Cells(cel.Row, 2)) = 1 Then
Cells(cel.Row, 20) = "a"
End If
If cel <> "" And Cells(cel.Row, 20).Value = "" And Len(Cells(cel.Row, 2)) = 2 Then
Cells(cel.Row, 20) = "B"
End If
If cel <> "" And Cells(cel.Row, 20).Value = "" And Len(Cells(cel.Row, 2)) = 3 Then
Cells(cel.Row, 20) = "C"
End If
If cel <> "" And Cells(cel.Row, 20).Value = "" And Len(Cells(cel.Row, 2)) = 4 Then
Cells(cel.Row, 20) = "D"
End If
If cel <> "" And Cells(cel.Row, 20).Value = "" And Len(Cells(cel.Row, 2)) = 5 Then
Cells(cel.Row, 20) = "E"
End If
'Etc .......
Next
End Sub
Quelqu'un verrait-il où le bas blesse?
Merci d'avance
Cordialement
Pièces jointes
Dernière édition: