The CSV file only has columns A through F but it is overwriting column G so G is blank after import.
If I open the CSV it stops at column F and I don't see anything in column G.
If I open the CSV it stops at column F and I don't see anything in column G.
VBA Code:
Sub Import_Azure_CSV_OLD()
Dim ws As Worksheet
Dim csvFilePath As Variant
Dim lastRow As Long
' Set the worksheet where you want to paste the data
Set ws = ThisWorkbook.Sheets("From Azure DB")
' Prompt the user to select the CSV file
csvFilePath = Application.GetOpenFilename(FileFilter:="CSV Files (*.csv), *.csv", Title:="Select CSV File")
' Check if the user selected a file or canceled the dialog
If csvFilePath = False Then
MsgBox "No file selected. Import canceled.", vbExclamation
Exit Sub
End If
' Clear existing data in the destination range starting from A9
ws.Range("A9").CurrentRegion.Clear
' Import the CSV file starting at row 9
With ws.QueryTables.Add(Connection:="TEXT;" & csvFilePath, Destination:=ws.Range("A9"))
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFilePlatform = xlWindows
.Refresh
End With
' Make row 9 bold
ws.Rows(9).Font.Bold = True
End Sub