OVH Cloud OVH Cloud

Aide sur code

2 réponses
Avatar
Michel
Bonjour à tout le monde,
Voici mon code mais ca ne marche pas au niveau du range.

Quelqu'un peut il m'aider?

Je vous en remercie par avance

Sub Laplage()
'
Range("C9").Select
a = selection.End(xlToRight).Address
Range("AH9").Select
b = selection.End(xlToLeft).Address

Dim c As Range
Rng = Range(Cells(9, a), Cells(9, b))
For Each c In Rng
If c.Value = "" Then
c.Interior.Color = vbGreen
End If
Next
End Sub

2 réponses

Avatar
Nicolas B.
Salut,

Il faut que a et b contiennent des numéros de colonne. Dans ton code ils
contiennent des addresses de cellules du type "$A$1".

Essaie :
a = selection.End(xlToRight).column
Range("AH9").Select
b = selection.End(xlToLeft).column


A+
Nicolas B.

Bonjour à tout le monde,
Voici mon code mais ca ne marche pas au niveau du range.

Quelqu'un peut il m'aider?

Je vous en remercie par avance

Sub Laplage()
'
Range("C9").Select
a = selection.End(xlToRight).Address
Range("AH9").Select
b = selection.End(xlToLeft).Address

Dim c As Range
Rng = Range(Cells(9, a), Cells(9, b))
For Each c In Rng
If c.Value = "" Then
c.Interior.Color = vbGreen
End If
Next
End Sub



Avatar
Michel
Bon j'ai trouver mon erreur, c'est pas address qu'il faut mais column .

Par contre maintenant quelqu'un peut m'aider à faire cela pour les lignes 9
à 90?


Bonjour à tout le monde,
Voici mon code mais ca ne marche pas au niveau du range.

Quelqu'un peut il m'aider?

Je vous en remercie par avance

Sub Laplage()
'
Range("C9").Select
a = selection.End(xlToRight).Address
Range("AH9").Select
b = selection.End(xlToLeft).Address

Dim c As Range
Rng = Range(Cells(9, a), Cells(9, b))
For Each c In Rng
If c.Value = "" Then
c.Interior.Color = vbGreen
End If
Next
End Sub