Please help with Macro

ariel20029

Board Regular
Joined
Jun 20, 2013
Messages
97
Hi all, I have a CSV file I need to open using notepad then import into exce when importing I need to convert Column X to text. The specific steps must be followed because if you do not open the CSV file with the notepad column X ends up with scientific notation due tot he long string of numbers. I found this macro to open the csv file with notepad but It says it can not locate the file. The text file is called b.csv and the folder is located on the C: drive in a folder called conversion. Also how do I tell it to take column X and make it TEXT and save to excel?
Thank you so much for all your help
Sharon

Sub importCSVFile()
Dim objWorkBook As Workbook
Dim myFile As String
srccsvfile = "C:\conversion\b.csv"
Workbooks.OpenText Filename:=myFile, Origin:=-535, StartRow:=1, _
DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter _
:=False, Tab:=False, Semicolon:=False, Comma:=False, Space:=False, _
Other:=True, OtherChar:=",", FieldInfo:=Array(Array(1, 1), Array(2, 2)), _
TrailingMinusNumbers:=True
Set objWorkBook = ActiveWorkbook
'do something with active WorkBook
End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Are you opening from file=>open or from data=>Get external=>from text if you do it from the latter, you will be able to format columns
1576844999355.png
 
Upvote 0

Forum statistics

Threads
1,223,933
Messages
6,175,481
Members
452,647
Latest member
MatthewBiersay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top