Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
Salve ho incollato quest'ultimo codice e all'apertura mi compare questo messaggio:
"errore run time 1004 errore definito dall'applicazione o dall'oggetto"
Grazie
Fabio
Per favore non si arrabbi con me :)
trovata la riga evidenziata:
blCondition = CBool(InStr(10, .Formula1, aDate, vbBinaryCompare))
Ciao Fabio,
Da me il codice funziona senza alcun problema e questo e' lo stesso codice che hai utilizzato da qualque tempo.
In ogni modo, nel modulo del codice del foglio LIQUIDI, sostituisci tutto il codice con la seguente versione:
'==========>>
Option Explicit
Const sIndirizzo As String = "I37:I51, D52:D55"
Const myFlag As String = "X"
'---------->>
Private Sub Worksheet_Activate()
Dim Rng As Range, Rng2 As Range
Dim rCell As Range
Dim sStr As String
Dim aDate As String
Dim iPos As Long
Dim Res As Variant
Dim blCondition As Boolean
aDate = Format(Date, "dd/mm/yy")
On Error GoTo XIT:
Set Rng = Me.Range(sIndirizzo)
For Each rCell In Rng.Cells
With rCell
If UCase(.Value) = UCase(myFlag) Then
With .Offset(0, 1).FormatConditions.Item(1)
blCondition = CBool(InStr(10, .Formula1, aDate, vbBinaryCompare))
If blCondition Then
If Not Rng2 Is Nothing Then
Set Rng2 = Union(Rng2, rCell)
Else
Set Rng2 = rCell
End If
End If
End With
End If
End With
Next rCell
If blCondition Then
Res = MsgBox(Prompt:="Attenzione vi sono parametri evidenziati." _
& vbNewLine _
& "sulle celle:" _
& vbNewLine & Rng2.Address(0, 0) & vbNewLine _
& "Vuoi deselezionarli?", _
Buttons:=vbYesNo, _
Title:="ATTENZIONE!")
If Res = vbYes Then
Application.EnableEvents = False
With Rng2
.ClearContents
.Offset(0, 1).FormatConditions.Delete
End With
Application.EnableEvents = True
End If
End If
XIT:
Call MsgBox(Prompt:="Error " & Err.Number & " (" & Err.Description & ")" _
& vbNewLine _
& "Address = " & rCell.Offset(0, 1).Address(0, 0) _
& vbNewLine _
& "Value= " & rCell.Value _
& vbNewLine _
& "CF Formula= " & rCell.Offset(0, 1).FormatConditions.Item(1).Formula1, _
Buttons:=vbCritical, _
Title:="ERRORE")
End Sub
'---------->>
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range, Rng2 As Range
Dim rCell As Range
Dim sDate As String
Set Rng = Me.Range(sIndirizzo)
Set Rng2 = Intersect(Rng, Target)
sDate = Format(Date + 1, "dd/mm/yy")
On Error GoTo XIT
Application.EnableEvents = False
Call Maiuscolo(Target)
If Not Rng2 Is Nothing Then
For Each rCell In Rng2.Cells
With rCell
With .Offset(0, 1).FormatConditions
If UCase(rCell.Value) = UCase(myFlag) Then
.Delete
.Add Type:=xlExpression, Formula1:= _
"=DATA.VALORE(" & Chr(34) & sDate & Chr(34) & ")=OGGI()"
.Item(1).Interior.Color = vbRed
ElseIf IsEmpty(rCell.Value) Then
.Delete
Else
Call MsgBox(Prompt:="Per favore, contrassegna la cella A con " _
& "la sola X", _
Buttons:=vbCritical, _
Title:="CONTRAVENZIONE DELLE NORME!")
rCell.ClearContents
.Delete
Exit Sub
End If
End With
End With
Next rCell
End If
XIT:
Application.EnableEvents = True
End Sub
'<<==========
Ora, quando il codice si blocca, per favore fammi sapere il contento del msgBox che riportera' l'errore.
===
Regards,
Norman