Bonjour
Je débute en VBA
J'ai bricolé ce petit bout de code mais je pense que l'on peut l'améliorer.
Mon souhait :
1° pour la Dim V, je voudrais qu'il prenne les cellules allant de B10 à B21 à chaque calcul
2° j'aurais aimé ne pas avoir à mettre 12 lignes identiques
Je suppose qu'il faut faire une sorte de boucle
J'espère que mon explication est claire
merci pour votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 Private Sub Worksheet_activate() Dim V V = Application.WorksheetFunction.VLookup(Range("B10"), Sheets("setup").Range("SetupImportMois"), 2, 0) Range("C10") = Application.CountA(Sheets("MOIS-MAAND").Range(V & "2" & ":" & V & Rows.Count)) Range("C11") = Application.CountA(Sheets("MOIS-MAAND").Range(V & "2" & ":" & V & Rows.Count)) Range("C12") = Application.CountA(Sheets("MOIS-MAAND").Range(V & "2" & ":" & V & Rows.Count)) Range("C13") = Application.CountA(Sheets("MOIS-MAAND").Range(V & "2" & ":" & V & Rows.Count)) Range("C14") = Application.CountA(Sheets("MOIS-MAAND").Range(V & "2" & ":" & V & Rows.Count)) Range("C15") = Application.CountA(Sheets("MOIS-MAAND").Range(V & "2" & ":" & V & Rows.Count)) Range("C16") = Application.CountA(Sheets("MOIS-MAAND").Range(V & "2" & ":" & V & Rows.Count)) Range("C17") = Application.CountA(Sheets("MOIS-MAAND").Range(V & "2" & ":" & V & Rows.Count)) Range("C18") = Application.CountA(Sheets("MOIS-MAAND").Range(V & "2" & ":" & V & Rows.Count)) Range("C19") = Application.CountA(Sheets("MOIS-MAAND").Range(V & "2" & ":" & V & Rows.Count)) Range("C20") = Application.CountA(Sheets("MOIS-MAAND").Range(V & "2" & ":" & V & Rows.Count)) Range("C21") = Application.CountA(Sheets("MOIS-MAAND").Range(V & "2" & ":" & V & Rows.Count)) End Sub
Partager