View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mikeyhend[_4_] Mikeyhend[_4_] is offline
external usenet poster
 
Posts: 1
Default Opening CSV in excel from VB


Hi,

You could try this:

Place this in a module in the *.xls that must open the *.csv
I used a button to trigger the macro and separated name and family
name.
If you need more than 2 columns, change array(2,1) to array(?,1) for
the number of columns you need in macro "Text_to_columns".


Sub openCSV()
Workbooks.Open "*:\*\*.csv"
Run "Text_to_columns"
End Sub
Sub Text_to_columns()

Range("A1").Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select
Selection.TextToColumns Destination:=Range("A1"),
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False,
Tab:=False, _
Semicolon:=True, Comma:=False, Space:=False, Other:=False,
FieldInfo _
:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Range("A1").Select
End Sub


--
Mikeyhend
------------------------------------------------------------------------
Mikeyhend's Profile: http://www.excelforum.com/member.php...o&userid=33400
View this thread: http://www.excelforum.com/showthread...hreadid=532572