Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

How to adding encoding function into Automated Text Import in Excel with File Selection

0

Hello I just watched youtube tutorial about set up a button to import .csv file. However, it wcan not show normally while I adding  .csv file using 65001: Unicode (UFT-8). Therefore, may I ask is ther any code that can solve this problem?

https://www.youtube.com/watch?v=EzUTK5hhjWM&t=997s&ab_channel=TeachExcel

Dim fileToOpen As Variant
Dim fileFilterPattern As String
Dim wsMaster As Worksheet
Dim wbTextImport As Workbook
Application.ScreenUpdating = False
fileToOpen = Application.GetOpenFilename(fileFilterPattern)
If fileToOpen = False Then
MsgBox "No file selected."
Else
Workbooks.OpenText _
Filename:=fileToOpen, _
StartRow:=2, _
DataType:=xlDelimited, _
Tab:=True
Set wbTextImport = ActiveWorkbook
Set wsMaster = ThisWorkbook.Worksheets("Data")
wbTextImport.Worksheets(1).Range("A1").CurrentRegion.Copy wsMaster.Range("A3")
wbTextImport.Close False
End If
Application.ScreenUpdating = True
End Sub
Answer
Discuss

Answers

0

I cant test the code right now but try changing the .csv to .txt for the file extension. If memory serves me, this should solve the issue.

Discuss


Answer the Question

You must create an account to use the forum. Create an Account or Login