範囲のオフセットを別の関数のクエリ テーブルの入力として渡す vba を作成しましたが、エラーが発生しました。
Sub test2()
Dim LastCol As Long
With ThisWorkbook.Sheets("Summary (AIX)")
LastCol = .Range("A2").SpecialCells(xlCellTypeLastCell).Column
End With
Dim r As Long
Dim ser_name As String
Dim y As String
For r = (LastCol - 1) To 2 Step -2
With ThisWorkbook.Sheets("Summary (AIX)")
y = Cells(2 + 2, r + 1).Address(RowAbsolute:=False, ColumnAbsolute:=False)
MsgBox CStr(Cells(2, r).Value)
ser_name = CStr(Cells(2, r).Value)
get_unix_avg_cpu ser_name, y
End With
Next r
End Sub
================================================== =======================
Sub get_unix_avg_cpu(server_hostname, x)
Dim oRS As ADODB.Recordset
Dim ConnString As String
Dim SQL As String
Dim qt As QueryTable
ThisWorkbook.Sheets(server_hostname).Activate
ConnString = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=test;User=root;Password=123456;Option=3;"
Set oCn = New ADODB.Connection
oCn.ConnectionString = ConnString
oCn.Open
SQL = "SELECT cpu_max_unix_0.CPU FROM test.cpu_max_unix cpu_max_unix_0 where cpu_max_unix_0.SERVER_NAME='" & server_hostname & "' Order By cpu_max_unix_0.LOGDATE"
Set oRS = New ADODB.Recordset
oRS.Source = SQL
oRS.ActiveConnection = oCn
oRS.Open
Set qt = ThisWorkbook.Sheets("Summary (AIX)").QueryTables.Add(Connection:=oRS, _
Destination:=ThisWorkbook.Sheets("Summary (AIX)").Range(x))
qt.Refresh
If oRS.State <> adStateClosed Then
oRS.Close
End If
If Not oRS Is Nothing Then Set oRS = Nothing
If Not oCn Is Nothing Then Set oCn = Nothing
End Sub
「Sub get_unix_avg_cpu(server_hostname, x)」で停止します コンパイル エラー: ユーザー定義型が定義されていません
助けてください!!