アットウィキロゴ

INSERT_SQL_CREATOR

Sub INSERT_SQL_CREATOR()
' テーブルに1行挿入する文を作成する'
Dim i
Dim sql_insert AS String
Dim sql_values AS String
i = 2
sql_insert = "INSERT INTO" & Cells(1,1).Value & "(" & Cells(2,1).Value
sql_values = "VALUES(" & Cells(3,1)
	Do Until Cells(2,i).Value = "END"
		sql_insert = sql_insert & "," & Cells(2,i).Value
		sql_values = sql_values &",'" Cells(3,i).Value & "'"
		i = i + 1
	Loop
sql_insert = sql_insert & ")"
sql_values = sql_values & ")"
Cells(5,1).Values = sql_insert & ")" & sql_values & ")"
 
END Sub
 
最終更新:2013年12月01日 23:23