ho una macro che mi preleva delle partite da un sito.
alcune volte xro il sito e' of.linee o non raggiungibile ,
e tale macro non mi si sblocca piu
non so come fermarla, devo chiudere excel in maniera forzata.
vorrei mettere un timer , ES 240 Sec
dopo il quale se la macro non ha finito esca dal ciclo,
con un mesg di errore, tipo - non risponde.
questa la macro in questione:
- Codice: Seleziona tutto
Sub Rettangoloarrotondato2_Click()
Dim r As Long
If MsgBox("ATTENZIONE!!!:" & vbNewLine & _
vbNewLine & _
" QUESTA FUNZIONE AGGIORNA GLI INCONTRI DEL GIORNO " & vbNewLine & _
vbNewLine & _
"LA DATA E' QUELLA GIUSTA?." & vbNewLine & _
vbNewLine & _
"SEI PROPRIO SICURO?", _
vbCritical + vbYesNo + vbDefaultButton2, "Cancellazione CELLA") = vbNo Then
Exit Sub
End If
UserForm1.Show vbModeless
DoEvents
Nascoste = 0
inizio = Timer
Application.ScreenUpdating = False
Sheets("partite").Visible = True 'visualizza
Worksheets("prono").Unprotect
Sheets("PARTITE").Select
Range("G4").Select
With Selection.QueryTable
.Connection = _
"URL;http://www.betonews.com/table.asp?tp=2002&lang=en&dd=" & [ab3] & "&dm=" & [ab4] & "&dy=" & [ab5] & "&df=1&dw=3"
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "25"
.WebPreFormattedTextToColumns = False
.WebConsecutiveDelimitersAsOne = False
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = True
.WebDisableRedirections = True
.Refresh BackgroundQuery:=False
End With
Sheets("PARTITE").Select
Range("R3:t10000").ClearContents
ctr = Range("X2") 'cella X2 di fgl partite
Range("G3:G" & ctr).Copy Range("R3")
Range("I3:I" & ctr).Copy Range("S3")
Range("C3:C" & ctr).Copy Range("T3")
r = Sheets("Partite").Cells(Rows.Count, 27).End(xlUp).Row
Columns(27).Select
Selection.AutoFilter
ActiveSheet.Range("$AA$1:$AA$" & r).AutoFilter Field:=1, Criteria1:="OK"
Range("R3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("PRONO").Select
Range("G7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("PARTITE").Select
Range("S3").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("PRONO").Select
Range("H7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("PARTITE").Select
Range("T3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("PRONO").Select
Range("C7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("PARTITE").Select
Range("AA1").Select
Selection.AutoFilter
Sheets("partite").Visible = False
Sheets("PRONO").Select
Application.Calculation = xlCalculationAutomatic
Call aggiorno_quote ' aggiorno tutte lequote
Range("V4") = Range("Z2")
'----nascondo righe con campion diversi-------------
'DISATTIVO LE APPLICATION PER VELOCIZZARE
'L'ESECUZIONE DELLA MACRO
Dim xlCal As XlCalculation
With Application
.ScreenUpdating = False
.EnableEvents = False
xlCal = .Calculation
.Calculation = xlCalculationManual
End With
'-----------------
For I = Range("e" & Rows.Count).End(xlUp).Row To 7 Step -1
If Cells(I, 5) <> Cells(I, 10) Then '5=E 10=j
Rows(I).Hidden = True
Nascoste = Nascoste + 1
End If
Next
'-------------------------------------------------------
'RIATTIVO LE APPLICATION
With Application
.Calculation = xlCal
.EnableEvents = True
.ScreenUpdating = True
End With
'-------------------------------------------------------
ActiveWindow.DisplayGridlines = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingColumns:=True, AllowFormattingRows:=True
Unload UserForm1
Cells(7, 3).Select
MsgBox "Sono state nascoste " & Nascoste & " righe"
fine = Timer
MsgBox ("Tempo impiegato " & Int((fine - inizio) / 60) & " min " & (fine - inizio) Mod 60 & " Sec")
End Sub
ciao