0

Removing info due to duplicate. please see

Using a range to input data to a filename

Community
  • 1
  • 1
E.Pyles
  • 9
  • 5
  • On which line is the error occurring? – mrbungle Jun 20 '16 at 15:33
  • 1
    Also you're going to run into the problem that your Efile value is stating the file name is `*$*.xlsx` . File names can't have an `*` in the file name. – mrbungle Jun 20 '16 at 15:37
  • Sorry for any difficulty; there is a $ in the file name. It works fine on file 1. – E.Pyles Jun 20 '16 at 15:43
  • try adding `msgbox EPath & EVar & EMo` before the `MkDir` line and post the result here. As @mrbungle said, you can't have a `*` in the filename. – 3-14159265358979323846264 Jun 20 '16 at 15:49
  • – 3-14159265358979323846264 , I did as you asked, used F8 to step through each call and the file path worked properly on every line. The box popped up, I said "ok" and the file opened. After removing the message box, the error came back. Why would it do that? – E.Pyles Jun 20 '16 at 15:54
  • Why try to open the file first and *then* check to see if the parent folder exists? Also, Workbooks.Open doesn't accept wildcards, so this isn't going to work... Maybe you need to explain in a little more detail exactly what you want to do. – Tim Williams Jun 20 '16 at 16:08
  • 1
    Why was my comment deleted? It's suddenly ok to ask duplicate questions on SO??? Not to mention, the other questions has _very telling_ information where OP states that `debug.print` shows `false` for `a2` which makes no sense/suggests pertinent info missing from question. But meh. – findwindow Jun 20 '16 at 16:17
  • Sorry guys. New to this exchange. Was hoping for a solution. Not sure what is being asked of me. I keep seeing that people are discussing debugging and wild cards. As I stated, the code works do the first file and works properly with the message box indicating the full file path (with wild card). Can someone please assist with what I need to do to make this an effective discussion. – E.Pyles Jun 20 '16 at 16:26
  • Edit your question to show the values in column A, the file names your looking for and which line is the error. Subscript out of range suggests you're referencing something that does not exist. – mrbungle Jun 20 '16 at 16:59
  • Just answer this - are all of your file named exactly as "*$*.xlsx" ? Or are they named something else ? Typically (when using `Dir()`) an asterisk is a *wildcard* meaning "zero or more other characters". You cannot pass wildcard filenames to `Open()`, and `*` cannot be part of an actual filename, so what you're trying to do here needs a full and complete explanation. People will help you if you can explain what it is you want to do. – Tim Williams Jun 20 '16 at 17:32
  • Tim, there are multiple files in the directory. The one I want to open has is named xxx_$_xxx.xsls. thr file name will change. The only constant is the dollar sign in the middle of the file. – E.Pyles Jun 20 '16 at 18:28
  • For the third time. On which line is the error? For me testing it without the open file this works through the cells. – mrbungle Jun 20 '16 at 19:39
  • mr bungle, It is saying that there is the run time error 9 on the second pass through the loop. It gets hung up on the Evar. It works all the way through if I close the excel file that opens. It seems to not be able to open multiple excel sheets at once. To test I added `ActiveWorkbook.Close` and it ran clean – E.Pyles Jun 20 '16 at 20:00
  • In that case see Andy's answer at the post marked as duplicate. – Tim Williams Jun 20 '16 at 20:25
  • Tim, I did use andy's response and it worked, however there is now a larger issue. Please see my comment to Mr. Bungle above your post. I have also edited the code above. – E.Pyles Jun 20 '16 at 21:15

0 Answers0