Importing a .csv file into excel

nynamyna

New Member
Joined
Jul 12, 2009
Messages
34
Hello everybody,

I know this is a common question. But, I tried doing it and I am not able to do it. I have a .csv file which I need to import into excel. I tried recording a macro but it is not dynamic. I need to do the following

1. When I run the macro it should let me to choose the .csv file

2. A new sheet should be created with the name of the csv file chosen and the data should be pasted in that sheet.

Please guide me so that I can do it.

Thanks,
Ram
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
You could try this simple macro which allows you to enter the file name:

Sub Macro2()


Name = InputBox("Please enter the name and path of the file to be imported: (i.e. c:\test.csv)", "Name", "xxxxx")
Workbooks.Open Filename:=Name
'Change "Book1" to your xls file name
ActiveSheet.Copy After:=Workbooks("Book1").Sheets(3)

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

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