tuanhuycntt
Thành viên chính thức


- Tham gia
- 5/7/15
- Bài viết
- 65
- Được thích
- 5
Vô tình đi lướt web dạo em tìm được 1 code này rất hay và share cho người nào cần.
Các anh chị có thể giúp em giải thích 1 số lệnh trong code để em hiểu nghĩa nó hơn ạ.
cho em hỏi biến Variant được dùng như nào ạ?
Code này được hiểu nghĩa như nào ạ?
Các anh chị có thể giúp em giải thích 1 số lệnh trong code để em hiểu nghĩa nó hơn ạ.
cho em hỏi biến Variant được dùng như nào ạ?
Mã:
On Error Resume Next
...
On Error GoTo 0
PHP:
Sub ImportCSVFile()
Dim xFileName As Variant
Dim Rg As Range
Dim xAddress As String
xFileName = Application.GetOpenFilename("CSV File (*.csv), *.csv", , "Kutools for Excel", , False)
If xFileName = False Then Exit Sub
On Error Resume Next
Set Rg = Application.InputBox("please select a cell to output the data", "Kutools for Excel", Application.ActiveCell.Address, , , , , 8)
On Error GoTo 0
If Rg Is Nothing Then Exit Sub
xAddress = Rg.Address
With ActiveSheet.QueryTables.Add("TEXT;" & xFileName, Range(xAddress))
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 936
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub