I have the following VBA code:
mainFile = ActiveWorkbook.Name
'select all excel files in this folder
fname = Dir(FPath & "\*.xls")
'go through all excel files in this folder
Do While fname <> ""
If (fname <> mainFile & fname <> uploadFile) Then
Debug.Print (mainFile & ":" & uploadFile & ":" & fname)
For some reason, the fname <> mainFile isn’t preventing it from entering the loop, and I get the following from the Debug.Print statement:
functions.xls:UPLOADME.xls:functions.xls
And then the code just stops executing…no error…just nothing (I have a Debug.Print after the loop that is ignored along with everything else)
Am I not comparing them correctly?
It should be:
fname <> mainFile And fname <> uploadFileIn VBA, the
&operator is used to concatenate strings, not to perform a logical AND… “And” is the operator I was looking for.