Ramo964516
03-01-2016, 04:47 AM
Hi everybody,
I was coding a loop, and i was wondering why my macro doesn't work. The idea of the macro is to determine the month's number of weeks. With knowing the name of the fisrt workday of a month i can countif the number of this occurence in a range of week's day. Her it is :
Dim dbNbSemaines As Double
Dim strAbrevJourMois As String
strAbrevJourMois = Range("E4").Value
If strAbrevJourMois = "lun" Then
Range("A404").FormulaR1C1 = "=COUNTIF(E4:AB4,""lun"")"
dbNbSemaines = Range("A404").Value
ElseIf strAbrevJourMois = "mar" Then
Range("A404").FormulaR1C1 = "=COUNTIF(E4:AB4,""mar"")"
dbNbSemaines = Range("A404").Value
ElseIf strAbrevJourMois = "mer" Then
Range("A404").FormulaR1C1 = "=COUNTIF(E4:AB4,""mer"")"
dbNbSemaines = Range("A404").Value
ElseIf strAbrevJourMois = "jeu" Then
Range("A404").FormulaR1C1 = "=COUNTIF(E4:AB4,""jeu"")"
dbNbSemaines = Range("A404").Value
ElseIf strAbrevJourMois = "ven" Then
Range("A404").FormulaR1C1 = "=COUNTIF(E4:AB4,""ven"")"
dbNbSemaines = Range("A404").Value
End If
When i go to the A404 cell that contains the countif formula it returns a #NOM? and it contains a =NB.SI('E4':'AB4';"lun"). How can i write it in vba to insert the range E4:AB4 in the COUNTIF formula ?
Thanks for your help
I was coding a loop, and i was wondering why my macro doesn't work. The idea of the macro is to determine the month's number of weeks. With knowing the name of the fisrt workday of a month i can countif the number of this occurence in a range of week's day. Her it is :
Dim dbNbSemaines As Double
Dim strAbrevJourMois As String
strAbrevJourMois = Range("E4").Value
If strAbrevJourMois = "lun" Then
Range("A404").FormulaR1C1 = "=COUNTIF(E4:AB4,""lun"")"
dbNbSemaines = Range("A404").Value
ElseIf strAbrevJourMois = "mar" Then
Range("A404").FormulaR1C1 = "=COUNTIF(E4:AB4,""mar"")"
dbNbSemaines = Range("A404").Value
ElseIf strAbrevJourMois = "mer" Then
Range("A404").FormulaR1C1 = "=COUNTIF(E4:AB4,""mer"")"
dbNbSemaines = Range("A404").Value
ElseIf strAbrevJourMois = "jeu" Then
Range("A404").FormulaR1C1 = "=COUNTIF(E4:AB4,""jeu"")"
dbNbSemaines = Range("A404").Value
ElseIf strAbrevJourMois = "ven" Then
Range("A404").FormulaR1C1 = "=COUNTIF(E4:AB4,""ven"")"
dbNbSemaines = Range("A404").Value
End If
When i go to the A404 cell that contains the countif formula it returns a #NOM? and it contains a =NB.SI('E4':'AB4';"lun"). How can i write it in vba to insert the range E4:AB4 in the COUNTIF formula ?
Thanks for your help