Created
June 27, 2016 06:14
-
-
Save teramako/4d68520943000ddcb1c238aa23187299 to your computer and use it in GitHub Desktop.
Excel VBAの標準モジュールに追加してる関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' ="SELECT ..... FROM ... WHERE column_A in ("&join(A1:A10,",","'")&")" などと式に使うことを想定 | |
' SQLインジェクション可能だが知らん。 | |
Function join(r As Range, Optional delimiter As String = ",", Optional wrap As String = "'") As String | |
Dim i As Integer | |
Dim result = As String | |
result = wrap & r.Cells(1, 1).Value & wrap | |
For i = 2 To r.rows.Count | |
result = result & delimiter & wrap & r.Cells(i, 1).Value & wrap | |
Next i | |
join = result | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment