What's wrong with this single line of code in VBA?

dan7055

Active Member
Joined
Jul 9, 2015
Messages
312
Code:
filecopy(CurrentPath & CSV_Files(i), MoveTo_Folder & CSV_Files(i))

When I click to go to a new line, VBA gives me a popup that says "Exepcted: ="
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,974
Office Version
  1. 365
Platform
  1. Windows
What is the value of each variable, try temporarily running this line of code in its place and see what it returns:
Code:
MsgBox CurrentPath & vbCrLf & Move_To_Folder & vbCrLf & CSV_Files(i)
Make sure that each value is valid, especially making sure that your file paths are valid and have a slash on the end.
And make sure that your file name is being returned.
 

dan7055

Active Member
Joined
Jul 9, 2015
Messages
312
What is the value of each variable, try temporarily running this line of code in its place and see what it returns:
Code:
MsgBox CurrentPath & vbCrLf & Move_To_Folder & vbCrLf & CSV_Files(i)
Make sure that each value is valid, especially making sure that your file paths are valid and have a slash on the end.
And make sure that your file name is being returned.

But that shouldn't matter though, it's giving me this error before I even run the code. It's giving me this error when I simply hit the enter button to do to writing the next line of code. It says there is a syntax error and requires and = sign. That doesn't make sense, all I want to do is copy a file from one folder to another.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,974
Office Version
  1. 365
Platform
  1. Windows
Try it without parentheses:
Code:
FileCopy CurrentPath & CSV_Files(i), MoveTo_Folder & CSV_Files(i)
It seems to like that.
 

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,406
Try it without the brackets, like this...

Code:
FileCopy CurrentPath & CSV_Files(i), MoveTo_Folder & CSV_Files(i)
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,123,402
Messages
5,601,475
Members
414,452
Latest member
Dannysamworth

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
Top