Koden indsættes i ThisWorkbook:
Private Sub workbook_activate()
Dim svar
svar = MsgBox("Opdatering af kurser?", vbYesNo)
If svar = 6 Then
hentKurser
fjernBlanke
End If
End Sub
Private Sub fjernBlanke() 'I kolonne A
For ræk = 2 To 1000
If Cells(ræk, 1) = "" Then
Exit Sub
Else
Cells(ræk, 1) = Left(Cells(ræk, 1), Len(Cells(ræk, 1)) - 1)
End If
Next ræk
End Sub
Private Sub hentKurser()
ActiveWorkbook.Sheets(1).Activate
Range("A1:G1000").Select
Selection.Clear
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;
http://trader.borsen.dk/borsendk/site/miniweb/miniweb.page?magic=(cc (level1 1) (level3 5))" _
, Destination:=Range("$A$1"))
.Name = "miniweb.page?magic=(cc (level1 1) (level3 5))"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveSheet.Columns.AutoFit
End Sub