Det er nu lykkedes. Min kode blev:
Sub adds()
Worksheets("Samlet").Select
Worksheets("Samlet").Activate
ActiveSheet.Cells.Clear
For x = 1 To 5
Worksheets("Input").Select
Worksheets("Input").Activate
mystr = "URL;
http://www.toyodiy.com/parts/xref?s=47771-32010"
mystr = Cells(x, 1)
Worksheets("Samlet").Select
Worksheets("Samlet").Activate
Range("A2").Select
Rows("1:20").Insert Shift:=xlDown
ActiveWorkbook.Sheets("Samlet").Range("A1").Value = mystr
With Sheets("Samlet").Range("A1")
If Left(.Value, 1) = "U" Then .Value = Right(.Value, Len(.Value) - 40)
End With
With ActiveSheet.QueryTables.Add(Connection:=mystr, Destination:=Range("$A$2"))
'.CommandType = 0
.Name = "xref?s=47771-32010"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "4"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveSheet.UsedRange.Select
'Deletes the entire row within the selection if the ENTIRE row contains no data.
Dim i As Long
'Turn off calculation and screenupdating to speed up the macro.
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
'Work backwards because we are deleting rows.
For i = Selection.Rows.Count To 1 Step -1
If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
Selection.Rows(i).EntireRow.Delete
End If
Next i
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
Next x
Columns("A:A").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = "=R[-1]C"
Worksheets("Samlet").Select
Worksheets("Samlet").Activate
Columns("A").ColumnWidth = 15
Columns("B").ColumnWidth = 15
Columns("C").ColumnWidth = 26
Columns("D").ColumnWidth = 39
Columns("E").ColumnWidth = 47
End Sub
På "input" angiver jeg stien til den tabel jeg ønsker for en bestemt reservedel.
På "samlet" kommer resultatet ud.