マクロ エクセル 最初の一滴

Sub sqlcmd()
Dim Ws As Worksheet
For Each Ws In Worksheets
Ws.Activate
If ActiveSheet.Name <> "説明" And ActiveSheet.Name <> "説明a" Then



Dim sql_cmd As String
sql_cmd = ":r """ & Range("B1").Value & "\"

Open ActiveSheet.Name & ".sql" For Output As #1
For i = 3 To 600
If Range("B" & i).Value = "" Then
Exit For
End If
Print #1, "Print " & sql_cmd & Range("B" & i).Value & """"
Print #1, sql_cmd & Range("B" & i).Value & """"
Print #1, "GO"
Next i
Close #1
End If
Next Ws
End Sub