Import CSVs Macro Error Troubleshooting. Please Help a Newbie Out!!

meg325

New Member
Joined
Aug 29, 2019
Messages
2
Hi all!

I'm super new to macros/vba and am working on a project for work that requires me to import csvs from a folder into a specific workbook. Each csv will need to go into a new sheet of this same workbook. I read around on the site to get the code I need to pull this off, but for some reason I'm getting a syntax error and my file path is highlighting red - even though its a valid file path (I've checked about 10 trillion times just to be extra sure). I've read several troubleshooting articles, but I'm at a loss and have no idea what I'm doing wrong.

Can someone PLEASE help and point me in the right direction? :confused:

Here's what I'm using:

HTML:
Sub ImportCSVs()

Dim fPath   As String
Dim fCSV    As String
Dim wbCSV   As Workbook
Dim wbMST   As Workbook

Set wbMST = ThisWorkbook

fPath = “C:\Users\morga\Desktop\dashboard\”
Application.ScreenUpdating = False
Application.DisplayAlerts = False
fCSV = Dir(fPath & “ * .csv”)

On Error Resume Next
Do While
 Len(fCSV) > 0      
Set wbCSV = Workbooks.Open(fPath & fCSV)      
ActiveSheet.Move After:=wbMST.Sheets(wbMST.Sheets.Count)
fCSV = Dir

Loop

Set wbCSV = Nothing
Application.ScreenUpdating = True

End Sub

Any help or direction would be SO appreciated!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi & welcome to MrExcel.

One possible problem is the quotes shown in your post are the wrong type, rather than “” they should be "" check to see what you have in your actual code & change is needed.
This affects both the fPath = line & the fCSV = line
 
Upvote 0
Ok perfect, thank you so much! :) That solved the error!

Now, it seems that I may be missing something in the code itself because when I run the macro nothing happens <sigh>. Do you see any glaring issues that would cause this? Or, do you have a better macro-based solution you could recommend?
 
Upvote 0
These two lines should be on one line
Code:
Do While
 Len(fCSV) > 0
 
Upvote 0
I would also Strongly recommend removing this line
Code:
On Error Resume Next
All it will do is mask any errors, so that you have no idea why the code is not doing what you think it should.
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,255
Members
448,556
Latest member
peterhess2002

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