![]() |
|
Forum
|
|
|
#1 (permalink) |
|
Guest
Messages: n/a
|
Bonsoir
Qui aurait la gentillesse de me modifier cette macro pour que je puisse faire 300 lignes (De A1 à A300)? Merci d'avance Pitou Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) If Not Application.Intersect(Target, Range("C1")) Is Nothing Then Select Case Target.Value Case Is = 1: Range("D1") = Range("A1") * Range("B1") Case Is = 2: Range("E1") = Range("A1") * Range("B1") Case Is = 3: Range("F1") = Range("A1") * Range("B1") Case Is = 4: Range("G1") = Range("A1") * Range("B1") End Select End If End Sub |
|
|
#2 (permalink) |
|
Guest
Messages: n/a
|
Bonsoir Pitou,
Je te propose : Private Sub Worksheet_Change(ByVal Target As Range) Dim L As Integer If Not Application.Intersect(Target, Range("C1:C300")) Is Nothing Then L = Target.Row Select Case Target.Value Case Is = 1: Cells(L, 4).Value = Cells(L, 1) * Cells(L, 2) Case Is = 2: Cells(L, 5).Value = Cells(L, 1) * Cells(L, 2) Case Is = 3: Cells(L, 6).Value = Cells(L, 1) * Cells(L, 2) Case Is = 4: Cells(L, 7).Value = Cells(L, 1) * Cells(L, 2) End Select End If End Sub Mais on peut faire plus simple : Private Sub Worksheet_Change(ByVal Target As Range) Dim L As Integer, C As Integer If Not Application.Intersect(Target, Range("C1:C300")) Is Nothing Then L = Target.Row C = Target.Value If C > 0 And C < 5 Then Cells(L, C + 3).Value = Cells(L, 1) * Cells(L, 2) End If End Sub Cordialement, Didier_mDF ![]() |
| ANNONCES | |
| Liens sociaux |
| Outils de la discussion | |
|
|