Zdravim poradakov!
Prejdem rovno k veci.
Mam makro, ktore stahuje data do excelu z internetu.
Vsetko funguje velmi dobre, akurat ze kod je prilis dlhy a tak som premyslal nad skratenim.
Nahodim tu cely kod, aby ste mali obraz>
toto je macro, ktore funguje, pride na stranku, vyberie z nej udaje a vlozi ich do excelu do bunky C10.
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
Sub macro.download()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.xxx" _
, Destination:=Range("$C$10"))
.Name = "1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = DeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingRTF
.WebTables = "5"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = True
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
Ale ak chcem , aby sa v tom istom sheete v bunke napriklad "$C$100" zjavilo tiez to iste, musim cely ten kod skopirovat a zmenit cielovu bunku v druhom kode.
Ak skopirujem druhy kod pred end sub, macro bude ako celok a oba kody prejdu jednum kliknutim, to viem, ale ja by som chcel, aby to vyzeralo nejak takto>>>
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
Sub macro.download()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.xxx" _
, Destination:=Range("$C$10"))
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.xxx" _
, Destination:=Range("$C$100"))
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.xxx" _
, Destination:=Range("$C$200"))
.Name = "1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = DeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingRTF
.WebTables = "5"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = True
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
end with
end with
End With
End Sub
'--------------------------------------------------------------------------------
'--------------------------------------------------------------------------------
Chcem dosiahnut, aby bol jeden kod, ktory povie>
Chod na tieto tri stranky a POTOM sprav nesledujuce(upravy a podobne)
Skusal som presne tento druhy kod, ale vzdy berie udaje len z posledneho kodu, teda do bunky C200 dostanem udaje, ale v bunkach C100 a C10 sa udaje neobnovia no a ja potrebujem, aby sa obnovovali.
Vie mi niekto poradit, aku syntax pouzit, aby to slapalo spravne?
Dakujem velmi pekne!