Bajar a la siguiente celda
Resuelto
Olive
-
Olive -
Olive -
Bonjour,
It bothers me to ask you something so simple, but I just started with VBA.
Problem No. 1:
Let me explain, I have a list of names like below and I would like to use a macro that allows me to bold the last name of each person.
Name1
Name1
Name1 => name in bold
Name2
Name2
Name2
Name2 => name in bold
Name3
Name3
Name3
Name3 => name in bold
Name4
Name4 => name in bold
Actually, I have a second problem:
Problem No. 2:
My number of lines in my list is random every week, so some weeks I may have 4 different names in my list or other weeks I may have a dozen different names. My problem here is that I can't set a random limit to my macro.
Here is my macro attempt:
Sub FR_NoircirVendeurs()
Dim Range As Range
Dim Cell As Range
Set Range = Range("B2:...") => my Problem No. 2
For Each Cell In Range
If Cell.Value = Cell.Offset(1, 0).Value Then
Step 1 => my problem No. 1 is here (I think)
End If
Next Cell
If Cell.Value <> Cell.Offset(1, 0).Value Then
Cell.Font.Bold = True
End If
Next Cell
End Sub
I hope I have been clear enough in my explanations.
Thank you in advance for any help you can provide.
Ps: thanks to commentcamarche.net which helps me in my VBA learning.
It bothers me to ask you something so simple, but I just started with VBA.
Problem No. 1:
Let me explain, I have a list of names like below and I would like to use a macro that allows me to bold the last name of each person.
Name1
Name1
Name1 => name in bold
Name2
Name2
Name2
Name2 => name in bold
Name3
Name3
Name3
Name3 => name in bold
Name4
Name4 => name in bold
Actually, I have a second problem:
Problem No. 2:
My number of lines in my list is random every week, so some weeks I may have 4 different names in my list or other weeks I may have a dozen different names. My problem here is that I can't set a random limit to my macro.
Here is my macro attempt:
Sub FR_NoircirVendeurs()
Dim Range As Range
Dim Cell As Range
Set Range = Range("B2:...") => my Problem No. 2
For Each Cell In Range
If Cell.Value = Cell.Offset(1, 0).Value Then
Step 1 => my problem No. 1 is here (I think)
End If
Next Cell
If Cell.Value <> Cell.Offset(1, 0).Value Then
Cell.Font.Bold = True
End If
Next Cell
End Sub
I hope I have been clear enough in my explanations.
Thank you in advance for any help you can provide.
Ps: thanks to commentcamarche.net which helps me in my VBA learning.
Configuration: Windows XP Internet Explorer 6.0
1 respuesta
-
Hola Olive,
sin pasar por VBA, puedes poner en negrita el último nombre utilizando el formato condicional (poner la celda en negrita si su contenido es diferente del contenido de la celda siguiente)
si quieres pasar obligatoriamente por tu macro:
1°) elimina completamente esta parte, que es incorrecta y no sirve para nada. El For Each ... Next pasa automáticamente de una celda a la siguiente, no es necesario añadir más.
If Cellule.Value = Cellule.Offset(1, 0).Value Then
Paso 1 => mi problema N° se encuentra aquí (creo)
End If
Next Cellule
2°) Dado que tus celdas a tratar están consecutivas, utiliza la función .End(xlDown) para encontrar el final de tu rango. Eso equivale a hacer Mayús+Ctrl+flecha abajo partiendo de B2.
Set Plage = Range(Range("B2"), Range("B2").End(xlDown))
I.