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: ="
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
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.
 
Upvote 0
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.
 
Upvote 0
Try it without parentheses:
Code:
FileCopy CurrentPath & CSV_Files(i), MoveTo_Folder & CSV_Files(i)
It seems to like that.
 
Upvote 0
Try it without the brackets, like this...

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

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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