Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ul> <li>You redim AllFiles but never fill it with anything. Is there missing code?</li> <li>AllFiles is a 0 based array so if you want to start at the second element you need to use test = 1 instead of test = 2.</li> <li><p>For looping through an array, try this:</p> <p><code>For test = 1 to ubound(AllFiles) - 1 'This loops through the array from the second element to the last</code></p></li> <li><p>Is "LastRow" a named range? If not, that's not going to work. The following will select the last used row in a worksheet:</p> <p><code>activesheet.Rows(activesheet.usedrange.rows.count).select</code></p></li> <li><p>Your SaveAs is failing because 1) AllFiles looks like it's never filled and 2) your save path as you wrote would be literally: <code>C:\Allfile(1)&amp;Allfiles(count)\.xlsm</code>. You want: </p> <p><code>ActiveWorkbook.SaveAs Filename:= "C:\" &amp; AllFiles(1) &amp; AllFiles(test) &amp; ".xlsm"</code></p></li> </ul> <p><strong>EDIT After Code Update</strong> </p> <ul> <li><p>You never initialize your count variable, add <code>count = 0</code> to the beginning just to be safe. </p></li> <li><p><code>GetOpenFilename</code> does in fact return the full path. Once you have that path stored in a variable (such as AllFiles()) you can get just the filename portion with <code>mid(AllFiles(test), instrrev(AllFiles(test), "\") + 1)</code></p></li> <li><p>You don't need the <code>ReDim AllFiles(count)</code> prior to your main Do Loop. ReDim erases the contents of the array unless you use the Preserve keyword.</p></li> <li><p>Change <code>Workbooks(AllFiles(test)).Activate</code> to <code>Workbooks(Mid(AllFiles(test), InStrRev(AllFiles(test), "\") + 1)).Activate</code> to strip the path information and leave just the filename.</p></li> <li><p><code>Windows("Allfiles(1).xml").Activate</code> won't work since your sending a literal string. You want <code>WORKBOOKS(Mid(AllFiles(1), InStrRev(AllFiles(1), "\") + 1)).Activate</code> here again.</p></li> <li><p><code>LastRow = LastRow + 1</code> probably isn't what you meant. Try <code>Set LastRow = LastRow.Offset(1, 0)</code></p></li> <li><p>Change <code>Range("LastRow").Select</code> to <code>LastRow.select</code></p></li> <li><p>All instances of <code>Windows(</code> should be changed to <code>Workbooks(</code></p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload