We have already taken care of the space character issue in previous code. SNB explained it again in his code. For Sam's code you need to add those quote characters to take care of the space characters.
Of course when you do this, checks for folder or filename existence use Dir() as I demonstrated, will fail. I normally just define a string as Sam did and then add the quote characters by concatenating them via q where q="""".
Const FolderPath As String = """C:\Users\dbrandejs\david\skola\IES\Diplomka\adjusted data\allstocks_20130102\""" 'include ending \
This is really something that you should be addressing. Use the debugging methods that I detailed in some past post here. We can only do so much for you.
We did some error checks but there are others that can be done.
Sub ken()
Dim FolderPath As String, q As String, fn As String, Msg As String
On Error GoTo ErrMsg
q = """"
FolderPath = "C:\Users\dbrandejs\david\skola\IES\Diplomka\adjusted data\allstocks_20130102\" 'include ending \
fn = q & FolderPath & q
MsgBox FolderPath & vbLf & "Exists? " & (Dir(FolderPath, vbDirectory) <> "")
'Next line will error:
MsgBox fn & vbLf & "Exists? " & (Dir(fn, vbDirectory) <> "")
'Exit Sub
ErrMsg:
If Err.Number <> 0 Then
Msg = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
Exit Sub
End If
End Sub