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!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
32,295
Office Version
365
Platform
Windows
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
 

meg325

New Member
Joined
Aug 29, 2019
Messages
2
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?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
32,295
Office Version
365
Platform
Windows
These two lines should be on one line
Code:
Do While
 Len(fCSV) > 0
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
32,295
Office Version
365
Platform
Windows
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.
 

Forum statistics

Threads
1,082,176
Messages
5,363,583
Members
400,752
Latest member
HamerTime7119

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top