il codice è contenuto in un file del server ed è il seguente:
- Codice: Seleziona tutto
Sub Riporta_Viaggio()
'
'porta i numeri viaggio e num spedizione in foglio cons pianificate
'
Dim LastA As Long, Last1 As Long, SummaSh As String, Cnt As Long, Rispo
Dim dayWkb As String, yNext As Long
'
SummaSh = "Cons Pianificate" '<<< Il foglio del file Annuale su cui fare la somma
'
Application.ScreenUpdating = False
Sheets("Foglio2").Select
dayWkb = ActiveWorkbook.Name
Sheets(2).Activate
Cnt = Application.WorksheetFunction.CountIf(ThisWorkbook.Sheets(SummaSh).Range("A:A"), Range("A2").Value)
If Cnt > 0 Then 'controlla se il codice è già presente in A:A
Rispo = MsgBox("Il numero di Viaggio è già presente in Cons Pianificate " & _
vbCrLf & "Vuoi sostituire i dati presenti (Si /No)?", vbYesNo)
If Rispo <> vbYes Then Exit Sub
End If
If Cnt > 0 Then 'se il codice è già presente in A:A elimina le righe che lo contengono
Do
myMatch = Application.Match(Range("A2").Value, ThisWorkbook.Sheets(SummaSh).Range("A:A"), 0)
If Not IsError(myMatch) Then
ThisWorkbook.Sheets(SummaSh).Cells(myMatch, "A").EntireRow.Delete
Else
Exit Do
End If
Loop
End If
LastA = Cells(Rows.Count, 1).End(xlUp).Row
Last1 = Cells(1, Columns.Count).End(xlToLeft).Column
yNext = ThisWorkbook.Sheets(SummaSh).Cells(65000, 1).End(xlUp).Row + 1
Range("A2").Resize(LastA - 1, Last1).Copy ThisWorkbook.Sheets(SummaSh).Cells(yNext, 1)
Windows("ELENCO CONSEGNE.xls").Activate 'elimina righe vuote in cons pianificate
Sheets("Cons Pianificate").Select
Range("A1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$B$31").AutoFilter Field:=1, Criteria1:="="
Rows("2:1000").Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter
Application.ScreenUpdating = True
Range("A2").Select
'
End Sub
e l'errore me lo dà verso la fine a questa riga:
Range("A2").Resize(LastA - 1, Last1).Copy ThisWorkbook.Sheets(SummaSh).Cells(yNext, 1)
Errore di runt ime 1004 definito dall'applicazione o dall'oggetto
questo codice funziona perfettamente su un PC con Office 2013 e su una altro con Office 2010, mi dà errore su un unico PC che sempre Office 2010 ma non en vengo a capo.
spero riusciate ad aiutarmi
Grazie sin d'ora