1
私のサブルーチンは個々のシートで実行するとうまく動作しますが、個別のシートごとに実行するには多くの問題がありました。サブルーチンはオンラインのCSVデータベースの簡単なクエリですが、最初のシートでは25回しか実行されません。なぜこれが私の人生のために把握することはできません。Excel VBAのトラブルシューティングシートと呼び出しサブルーチン
私はこの同じループで計算を実行できましたが、各シート上でサブルーチンを実行することができませんでした。
Sub Datacollection()
Dim ws As Worksheet
For Each ws In Worksheets
ws.Application.Run "Gethistory"
Next ws
End Sub
Sub Gethistory()
Dim Target As Variant
Dim Name As Variant
'
Set Target = Range("B1")
Set Name = Range("B2")
With ActiveSheet.QueryTables.Add(Connection:= _
"Text;" & Target, _
Destination:=Range("$A$3"))
.Name = Name
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub