"runtime error:1004 Application defined or object defined error".
Sub Macro1() ' ' Macro1 Macro ' ' Keyboard Shortcut: Ctrl+w ' For x = 1 To 10 Worksheets("Sheet4").Select Worksheets("Sheet4").Activate mystr = Cells(x, 1) Worksheets("Sheet1").Select With ActiveSheet.QueryTables.Add(Connection:=mystr, Destination:=Range("$A$1")) .Name = "490462_1" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = False .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlEntirePage .WebFormatting = xlWebFormattingRTF .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With Range("A6:A9").Select Selection.Copy Sheets("Sheet2").Select Range("A" & x + 5).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Sheets("Sheet1").Select Range("A387:A388").Select Application.CutCopyMode = False Selection.Copy Sheets("Sheet2").Select Range("B" & x + 5).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("A6").Select Sheets("Sheet1").Select Cells.Select Range("A371").Activate Application.CutCopyMode = False Selection.QueryTable.Delete Selection.ClearContents Sheets("Sheet1").Select Next x End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)