automating copying data from .csv file to a xlsm file with a dialog box

sairampappu

New Member
Joined
Nov 19, 2017
Messages
7
Hi

I am trying to import a .csv file into a .xlsm sheet and copy the whole data. Actually I have code in such a way that the input file(raw data .csv file) is open (should be activated), then only the macro is running. So I need to modify the code in a way that " If I press select file button, a dialog box should open then I should select any .csv input file and the whole data .
Please help me out.

Thanks,
Sai
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
This will allow you to select a csv file & it will then open it.
Code:
Sub OpenFile()

    Dim FName As String
    
    FName = Application.GetOpenFilename(FileFilter:="CSV Files (*.csv), *.csv", Title:="Select a .csv file", MultiSelect:=False)
    If FName = False Then
        MsgBox "no file selected"
        Exit Sub
    Else
        Workbooks.Open FName
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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