0

ok so this is a short peace in a big workbook... All i am trying to do is tell it a certain place to save.

ActiveWorkbook.SaveCopyAs _
    FileName:=ActiveWorkbook.Path "\OLD " & Range("D1").Value & ".XLSM"

This does exactly as it is supposed to however, i want to say basically "activeworkbook.path" plus give it one further step and designate a folder called "old" that it will go to.

in essence it would look like this

\documents\test\my-file.xlsm

to this

\documents\test\OLD\my-file.xlsm

any hints?

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
Daniel Roy
  • 105
  • 8

1 Answers1

2

You have a space in "\OLD ", and you are not closing off \OLD to be a folder.

The line should look like

ActiveWorkbook.SaveCopyAs _
    FileName:=ActiveWorkbook.Path & "\OLD\" & Range("D1").Value & ".XLSM"

I would also strongly consider qualifying your Range("D1") with your worksheet.

Dim fileNameRng as range
Set fileNameRng = thisworkbook.worksheets("Sheet1").Range("D1")

ActiveWorkbook.SaveCopyAs _
    FileName:=ActiveWorkbook.Path & "\OLD\" & fileNameRng.Value & ".XLSM"
K.Dᴀᴠɪs
  • 9,945
  • 11
  • 33
  • 43
  • One simple little back slash just made me feel like an idiot!!! Out of curiosity what is the point of qualifying the range vs just having it straight in code? – Daniel Roy Nov 12 '18 at 04:00
  • 2
    It's good practice. One day you may not be on the correct worksheet (or workbook) and the value will pull from somewhere that you didn't intend for it to. – K.Dᴀᴠɪs Nov 12 '18 at 04:02