Last active
July 31, 2021 01:24
-
-
Save stevesohcot/4a6cb6b3fda2e565176dd0676519e619 to your computer and use it in GitHub Desktop.
VBA Import data single row
This file contains hidden or 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
| Public Function getSQLForSingleRow(sheet As String, rowNumber As Long) As String | |
| ' Be sure to update any formatting; ex date or number | |
| fieldWithText = ReplaceSingleQuote(Worksheets(sheet).Range("A" & rowNumber).FormulaR1C1) | |
| fieldWithDate = Format(Worksheets(sheet).Range("B" & rowNumber).FormulaR1C1, "mm/dd/yyyy") | |
| fieldWithNumbers = CDbl(Nz(Worksheets(sheet).Range("C" & rowNumber).FormulaR1C1)) | |
| Dim strSQL As String | |
| strSQL = " (" | |
| strSQL = strSQL & " '" & fieldWithText & "'," | |
| strSQL = strSQL & " '" & fieldWithDate & "'," | |
| strSQL = strSQL & " " & fieldWithNumbers & "" ' no quotes because it's numeric | |
| strSQL = strSQL & " ) " | |
| getSQLForSingleRow = strSQL | |
| End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment