Ciao Mykia55,
Provato ma mi risponde errore run time '1004'
non è stata trovata alcuna cella
ho integrato il tuo codice in questo:
Public Sub Tester()
Sheets("1").Unprotect Password:="!Qazxsw2"
Dim Miorange As Range
Dim cel As Range
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range, Rng2 As Range, rCell As Range
Dim CalcMode As Long
Set Miorange = Range("CX3017:DW3100")
For Each cel In Miorange
If cel.Value = "" Then cel.Value = 0
Next cel
Range("cx2956:dd3016").Select 'celle da copiare
Selection.Copy
Sheets("1").Select ' foglio dove copiare
Range("df2956:dl3016").Select 'celle dove copiare
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Const sFoglio As String = "1"
Const sIntervallo As String = "DF2956:DL3016"
Set WB = ThisWorkbook
Set SH = WB.Sheets(sFoglio)
Set Rng = SH.Range(sIntervallo)
Set Rng2 = Rng.SpecialCells(xlCellTypeBlanks) 'qua si ferma il debug
If Not Rng2 Is Nothing Then
On Error GoTo XIT
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
Rng2.Delete Shift:=xlUp
End If
XIT:
With Application
.Calculation = CalcMode
.ScreenUpdating = True
End With
End Sub
Il mio codice funzionerebbe senza problemi purchè si siano delle celle vuote nell'intervallo DF2956:DL3016. Con questo codice, per evitare un messaggio di errore se non ci dovessero essere celle vuote, sostituisci:
Set Rng2 = Rng.SpecialCells(xlCellTypeBlanks) 'qua si ferma il debug
If Not Rng2 Is Nothing Then
On Error GoTo XIT
con:
On Error GoTo XIT
Set Rng2 = Rng.SpecialCells(xlCellTypeBlanks) 'qua si ferma il debug
If Not Rng2 Is Nothing Then
Tornando al tuo adattamento del mio codice, va notato che le istruzioni
Set Miorange = Range("CX3017:DW3100")
For Each cel In Miorange
If cel.Value = "" Then cel.Value = 0
Next cel
sostitiurebbe le celle vuote con celle contenenti il valore 0. Pertanto, riscontreresti il l'errore indicato oppure, se dovessi modificare il mio codice come suggerito, il codice non fornirebbe errori ma non farebbe niente poichè non troverebbe alcuna cella
vuota da spostare.
===
Regards,
Norman
