I use PowerQuery to create a table from databases and manage files.
There are some files I need to move to a specific folder, depending the value in some column. No need in my VBA code to check those, all the various checks are done with PowerQuery.
THere is in fact more column in my table, but the 3 I look at in the macro are those 3.
| OriginalNativeName | NewNativeName | completepath\newfolder |
|---|---|---|
| complete path folder1Newfilename1 | complete path folder1Newfilename1 | complete path folder1 |
| complete path folder2 | ||
| complete path folder1filename 3 | complete path folder1Newfilename3 | complete path folder1 |
My VBA code is just to move the files listed in my generated table. Some line are blank because there is no file or no need to rename ( but other columns are needed, so I cannot delete my line completely).
I need to create the folder, if needed, before moving my files. but I also need to skip the lines that are blank and it’s here I have error.
My last attempt as code is the following one, where I try to skip the renaming.
Sub Move_Native()
Dim TAncNouv(), L&
Dim Fobj As Object
Set Fobj = CreateObject("scripting.filesystemobject")
ChDrive ThisWorkbook.Path: ChDir ThisWorkbook.Path
TAncNouv = ActiveSheet.Range("xml_ENGDOC[OriginalNativeName]").Resize(, 3).Value
For L = 1 To UBound(TAncNouv, 1)
If Fobj.FolderExists(TAncNouv(L, 3)) = False Then
MkDir (TAncNouv(L, 3))
End If
If IsEmpty(TAncNouv(L, 1)) = True Then
Else
Name TAncNouv(L, 1) As TAncNouv(L, 2)
End If
Next L
End Sub
But I still have an Run Time error ’75’: Path/File access error:

so it means I’m not skipping correctly. What am I doing wrong ? what can I do to skip this part ?
Thanks in advance
>Solution :
IsEmpty is designed to be used on objects, to identify if they’ve been initialised or not. You shouldn’t really use them on cell objects in this way.
To test if a cell contains no data, use:
If TAncNouv(L, 1) =vbNullString