Hi;
Can anyone please help me!!!
I'm trying to do a Macro that is supose to open a file(the user has to choose the .csv) with a button and then copy the .csv data and paste in the another WorkBook(this workbook has the button to browse the "Open Dialog")
This is the code that I have
Private Sub cmdLoad_Click()
Call Load 'I call the macro
End Sub
Sub Load()
Dim fopen As Variant
fopen = Application.GetOpenFilename("Comm Separated Value Files (*.csv), *.csv") 'Here is where I browse the Open Dialog
If fopen <> False Then
Workbooks.OpenText Filename:=fopen, startrow:=1, DataType:=xlDelimited, _
TextQualifier:=xlTextQualifierDoubleQuote, Tab:=False, Semicolon:=False, comma:=False, _
decimalSeparator:=".", thousandsSeparator:=","
' In this part is where I get lost, I don't know the code to copy the data of the .csv file or how paste it in the other workbook
End If
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & fopen _
, Destination:=Range("A1"))
.Name = fopen
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1)
.Refresh BackgroundQuery:=True
End With
End Sub
thanks for the help
Xoxo
Lily
Can anyone please help me!!!
I'm trying to do a Macro that is supose to open a file(the user has to choose the .csv) with a button and then copy the .csv data and paste in the another WorkBook(this workbook has the button to browse the "Open Dialog")
This is the code that I have
Private Sub cmdLoad_Click()
Call Load 'I call the macro
End Sub
Sub Load()
Dim fopen As Variant
fopen = Application.GetOpenFilename("Comm Separated Value Files (*.csv), *.csv") 'Here is where I browse the Open Dialog
If fopen <> False Then
Workbooks.OpenText Filename:=fopen, startrow:=1, DataType:=xlDelimited, _
TextQualifier:=xlTextQualifierDoubleQuote, Tab:=False, Semicolon:=False, comma:=False, _
decimalSeparator:=".", thousandsSeparator:=","
' In this part is where I get lost, I don't know the code to copy the data of the .csv file or how paste it in the other workbook
End If
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & fopen _
, Destination:=Range("A1"))
.Name = fopen
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1)
.Refresh BackgroundQuery:=True
End With
End Sub
thanks for the help
Xoxo
Lily