- Codice: Seleziona tutto
Sub ContaCns()
Dim P As Integer, D As Integer, a As String, b As String, c As String
rr = Cells(Rows.Count, 1).End(xlUp).Row
Range(Cells(1, 45), Cells(rr, 46)).ClearContents
For x = 1 To rr
P = 0
D = 0
For y = 1 To 6
If Cells(x, y) = "P" Then
If y = 1 Then P = 1
If y > 1 Then
If Cells(x, y - 1) = "D" Then
P = 1
Else
If Cells(x, y - 1) = "P" Then P = P + 1
End If
End If
End If
If Cells(x, y) = "D" Then
If y = 1 Then D = 1
If y > 1 Then
If Cells(x, y - 1) = "P" Then
D = 1
Else
If Cells(x, y - 1) = "D" Then D = D + 1
End If
End If
End If
Next y
Cells(x, 45) = P
Cells(x, 46) = D
Next x
End Sub
- ora il mio problema è che nelle celle da controllare ho la formula:
"=SE(RESTO(C1:C176;2)>0;"D";"P")
per cui se lancio la macro non mi funziona in quanto legge nelle celle la formula e non la lettera D o P come faccio a risolvere il problema???
grazie a tutti