pedrinhogui
New Member
- Joined
- Jun 29, 2020
- Messages
- 4
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
- MacOS
Hello guys,
Hope you are well!
I have a VBA code to import CSV files to my excel that works fine, however because now I will have more users using it, I need to change this code to something more simple for users ( the actual code gets the CSV file from a path that I did set on the VBA code). I would like to change it for an option that makes it possible to users to find the CSV file in their computer. I think the function name it's " Application.GetOpenFilename ". I have tried to change my code, but unfortunattely I couldn't do it. ALso, I have tried to find another ready CSV import codes, but they all mess with the CSV data ( I dont know why), so I'd like to stick with this one because so far works very well.
May someone help me?
Thank you very much.
Kind Regards
That's the original code:
Hope you are well!
I have a VBA code to import CSV files to my excel that works fine, however because now I will have more users using it, I need to change this code to something more simple for users ( the actual code gets the CSV file from a path that I did set on the VBA code). I would like to change it for an option that makes it possible to users to find the CSV file in their computer. I think the function name it's " Application.GetOpenFilename ". I have tried to change my code, but unfortunattely I couldn't do it. ALso, I have tried to find another ready CSV import codes, but they all mess with the CSV data ( I dont know why), so I'd like to stick with this one because so far works very well.
May someone help me?
Thank you very much.
Kind Regards
That's the original code:
VBA Code:
Sub LoadFromFile1()
Dim FileName As String, folder As String
folder = "C:\Users\Pedrogui\Downloads\Report.csv"
FileName = ActiveCell.Value
ActiveCell.Offset(0, 0).Range("A1").Select
With ActiveSheet.QueryTables _
.Add(Connection:="TEXT;" & folder & FileName, Destination:=ActiveCell)
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
MsgBox "Update Completed!"
End Sub