vba to query문

vba로 간단하게 엑셀의 데이터를 업데이트 문 만들기…



개발탭클릭->Visual basic 클릭->시트1클릭.

아래 코드를 붙여넣기

Sub default()
   Dim SQL As String
   Dim i As Long

   For i = 2 To 2
   SQL = "UPDATE  `db명`.`테이블명` SET  "
   '칼럼이 만으면  (i, 2), (i, 3), (i, 4)로 조함
   SQL = SQL & "`칼럼명` = '" & Sheet1.Cells(i, 1).Value & "', " & vbNewLine
   SQL = SQL & " WHERE  `xe_school_data`.`document_srl` =" & Sheet1.Cells(i, 110)
   '시트2의 칼럼에 케리문을 양도함
   '.sql파일로 만들어서 저장해도 됨.
   Sheet2.Cells(i, 1).Value = SQL
   Next i

End Sub

이렇게 하면 일일이 sql문을 만들필요 없음.


One thought on “vba to query문”

  1. I’m still learning from you, while I’m improving myself. I certainly liked reading all that is posted on your blog.Keep the stories coming. I liked it!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.