Olá pessoal, não sou programador, e tenho uma planilha com concursos da lotofácil onde faço meus joguinhos, e gostaria de atualizar os resultados automaticamente sem ter que ficar copiando direto (ainda mais que agora os sorteios ocorrem todos os dias).
Encontrei uma macro em um fórum, atribuí a macro ao botão, conforme código abaixo, mas toda vez que clico no botão aparece a seguinte Msg de erro:
Erro no tempo de execução '1004':
Erro definido por aplicativo ou por objeto
Tentei fazer algumas alterações mediante pesquisas em dúvidas sobre esse erro, mas não consegui. Se algum colega souber como resolvo essa parada, ficaria muito grato!
Segue abaixo o código da macro:
Sub Botão1_Clique()
Application.ScreenUpdating = False
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & "http://loterias.caixa.gov.br/wps/portal/loterias/landing/lotofacil/!ut/p/a1/04_Sj9CPykssy0xPLMnMz0vMAfGjzOLNDH0MPAzcDbz8vTxNDRy9_Y2NQ13CDA0sTIEKIoEKnN0dPUzMfQwMDEwsjAw8XZw8XMwtfQ0MPM2I02-AAzgaENIfrh-FqsQ9wBmoxN_FydLAGAgNTKEK8DkRrACPGwpyQyMMMj0VAcySpRM!/dl5/d5/L2dBISEvZ0FBIS9nQSEh/pw/Z7_HGK818G0K85260Q5OIRSC42046/res/id=historicoHTML/c=cacheLevelPage/=/" _
, Destination:=Range("$B$2"))
.Name = "transaction"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
Range("A1").Select
.Refresh BackgroundQuery:=False
End With
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1 _
), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array _
(20, 1), Array(21, 1), Array(22, 1)), TrailingMinusNumbers:=True
Cells.ColumnWidth = 5
Range("A1").Select
End Sub