modifier formule dans macro
bonjour le forum
j'ai une macro et je voudrais y inserer une formule dont les valeurs change a chaque clique de macro.Cette formule c'est "=NB.SI(Feuil1!$B$2:$F$41;A6)"les valeurs qui doivent changer sont le 2 et 41 qui passeront a 3 et 42.Voici le code,le code doit s'inserer entre "End With" et "Range("A6:B54").Copy".
Mais comment inscrire ce code.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| Sub Macro4()
' Macro4 - 40-Auto
Dim plg As Byte
Dim dlg As Integer, vligne As Integer
dlg = Range("L" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = True
For plg = 34 To dlg
With Range("H" & plg & ":L" & plg)
.Copy Range("C1")
.ClearContents
End With
Range("A6:B54").Copy
Range("C6").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
With ActiveWorkbook.Worksheets("40").Sort
.SortFields.Clear
.SortFields.Add Key:=Range("D6:D54"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SetRange Range("C6:D54")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Calculate
'Range("G5").Select
vligne = Range("AD65536").End(xlUp).Row + 1
Range("C3:G3").Copy
Range("AD" & vligne).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Dim Cellule As Range
Dim Plage As Range
Dim i, l, c As Integer
i = 6
Set Plage = Range("C1:G1")
While IsEmpty(Range("A" & i)) = False
For Each Cellule In Plage
If Range(Cellule.Address).Value = Range("C" & i).Value Then
l = Range("E" & i).Value + 8
c = Range("F" & i).Value + 10
Cells(c, l) = Cells(c, l) + 1
End If
Next Cellule
i = i + 1
Wend
Next
Application.ScreenUpdating = False
Range("G5").Select
End Sub |
merci
modifier formule dans macro
bonjour jfontaine,le forum
merci pour le code
bonne journée