Quote Originally Posted by westconn1 View Post
you still needed the first part of your code, to select the files, but

if you just want all the files in a specific directory, then you do not need to use getopenfilename
change the loop of xlfiles to
vb Code:
  1. srcfolder = ' your path with trailing \
  2. fname = dir(srcfolder & "*.xlsx")  ' get first file name to match pattern
  3. do until len(fname) = 0  ' stop loop when no more files found
  4. set wbk = workbooks.open(srcfolder & fname)
  5.   set sht = wbk.sheets("sheet1")  ' set sheet object, change sheet name to suit, or use index
  6.   ' do all processing with workbook
  7.   wbk.saveas savfolder & fname
  8.   wbk.close
  9.   fname = dir   ' get next file name
  10. loop
use wbk or sht objects, at all times to refer to the workbook you are processing, avoid using activeworkbook as this can lead to errors, all ranges or cells are then ranges within the sht object
also use trailing backslash for savfolder
saveFolder = "C:\Users\DTurcotte\Desktop\VBA Target\"

you can then use like
vb Code:
  1. with sht
  2.    If .Cells(1, 1).Value <> "ROOM #" Then .Cells(1, 1).Value = "ROOM #"
  3.    'etc
  4. end with
if you always look to see if the value is not a value then set it to a value, it is probably faster to just set the value whether it is or not the value already, you should also turn off screenupdating too application.screenupdating = false.
if you want to use totalrows variable it should be assigned a value for each workbook after it is open
Awesome...
Thank you for your help.

I ended up changing:

If Cells(1, 1).Value <> "ROOM #" Then Cells(1, 1).Value = "ROOM #"
If Cells(1, 2).Value <> "ROOM NAME" Then Cells(1, 2).Value = "ROOM NAME"
If Cells(1, 3).Value <> "HOMOGENEOUS AREA" Then Cells(1, 3).Value = "HOMOGENEOUS AREA"

To:

an array...
ColumnHeading = Array("ROOM #", "ROOM NAME", "HOMOGENEOUS AREA", ...

Code looks nice and smooth.