I have a problem with my VBA macro that should transfer data automatically from C:\Temp\lingoni folder. Excel says that it can't find the files even tough they are at the folder and named correctly imo (?). The macro find's folders but not the files insde.
In option explicit:
Const keno = "\"
Const alaviiva = "_"
Const jatke = ".xlsx"
And this is the Sub that should find the first file from C:\Temp\lingoni which is named as "2013_9_1" and the other 3 files are the same except that the last number is between 2-4. In the sub "vuosi" means year in Finnish language and "tehdas" means factory. I have named one cell as "vuosi" and other as "tehdas". Data_kansio is a name of one cell where I have writen "C:\Temp\lingoni" and "bu_kansio" is the name of backup folder inside lingoni folder.
Macro:
Function prosessilupa() As Boolean
' this function checks if the there are 2 folders and 4 files at the folder
Dim is_ok As Boolean
is_ok = True
'are there 2 folders?
If Dir(data_kansio, vbDirectory) = "" Then
MsgBox ("There's no weekly data folder")
is_ok = False
End If
If Dir(bu_kansio, vbDirectory) = "" Then
MsgBox ("There's no backup folder")
is_ok = False
End If
'are all 4 files inside the folders?
If is_ok Then
tehdas = 1
Do
datatdo = vuosi & alaviiva & viikko & alaviiva & tehdas & jatke 'datatdo on 1 tehtaan tiedot
If Dir(data_kansio & keno & datatdo) = "" Then
MsgBox ("Viikkodata puuttuu: tehdas " & tehdas)
is_ok = False
End If
tehdas = tehdas + 1
Loop Until tehdas > tehdaslkm Or Not is_ok
End If
prosessilupa = is_ok
End Function
Any ideas?
Bookmarks