Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Nommer champs avec macro

2 réponses
Avatar
Vincent_C
bonjour à tous et excellente nouvelle année 2009 !

la macro suivante permet de nommer des colonnes à partir d'un nom situé sur
une ligne donnée :


Sub Nommer_Colonnes_Selon_Ligne_n()
Dim nom As String

Set f = Worksheets("onglet")
For i = 42 To 53
If Left(Cells(3, i), 1) = "V" Then
nom = Cells(244, i)
Else
nom = "_" & Cells(244, i)

End If
Set ici = f.Columns(i)
ActiveWorkbook.Names.Add Name:=nom, RefersTo:=ici
Next i
End Sub

Comment adapter la macro pour faire en sorte que le nombre de lignes soit
également indiqué (par exemple le nom ferait référence à AP244:AP5000 et non
plus AP:AP)

Merci d'avance !

Bien cordialement,

Vincent_C

2 réponses

Avatar
Daniel.C
Bonjour.
Essaie :

Sub Nommer_Colonnes_Selon_Ligne_n()
Dim nom As String
Set f = Worksheets("onglet")
For i = 42 To 53
If Left(Cells(3, i), 1) = "V" Then
nom = Cells(244, i)
Else
nom = "_" & Cells(244, i)

End If
f.Range(Cells(244, i), Cells(5000, i)).Name = nom
Next i
End Sub

Cordialement.
Daniel

bonjour à tous et excellente nouvelle année 2009 !

la macro suivante permet de nommer des colonnes à partir d'un nom situé sur
une ligne donnée :


Sub Nommer_Colonnes_Selon_Ligne_n()
Dim nom As String

Set f = Worksheets("onglet")
For i = 42 To 53
If Left(Cells(3, i), 1) = "V" Then
nom = Cells(244, i)
Else
nom = "_" & Cells(244, i)

End If
Set ici = f.Columns(i)
ActiveWorkbook.Names.Add Name:=nom, RefersTo:=ici
Next i
End Sub

Comment adapter la macro pour faire en sorte que le nombre de lignes soit
également indiqué (par exemple le nom ferait référence à AP244:AP5000 et non
plus AP:AP)

Merci d'avance !

Bien cordialement,

Vincent_C


Avatar
Vincent_C
Vraiment super, ça marche impeccable. Merci beaucoup et très bonne journée !

Bien cordialement,

Vincent_C

"Daniel.C" a écrit :

Bonjour.
Essaie :

Sub Nommer_Colonnes_Selon_Ligne_n()
Dim nom As String
Set f = Worksheets("onglet")
For i = 42 To 53
If Left(Cells(3, i), 1) = "V" Then
nom = Cells(244, i)
Else
nom = "_" & Cells(244, i)

End If
f.Range(Cells(244, i), Cells(5000, i)).Name = nom
Next i
End Sub

Cordialement.
Daniel

> bonjour à tous et excellente nouvelle année 2009 !
>
> la macro suivante permet de nommer des colonnes à partir d'un nom situé sur
> une ligne donnée :
>
>
> Sub Nommer_Colonnes_Selon_Ligne_n()
> Dim nom As String
>
> Set f = Worksheets("onglet")
> For i = 42 To 53
> If Left(Cells(3, i), 1) = "V" Then
> nom = Cells(244, i)
> Else
> nom = "_" & Cells(244, i)
>
> End If
> Set ici = f.Columns(i)
> ActiveWorkbook.Names.Add Name:=nom, RefersTo:=ici
> Next i
> End Sub
>
> Comment adapter la macro pour faire en sorte que le nombre de lignes soit
> également indiqué (par exemple le nom ferait référence à AP244:AP5000 et non
> plus AP:AP)
>
> Merci d'avance !
>
> Bien cordialement,
>
> Vincent_C