1

We use a formatter every day for a set of our files. The file naming convention used to be "XX000". Now, the files are named like this: "XX000-YYYY-MM-DD". I want to be able to add a date function to the VBA code so users can still enter the basic XX000 name into the InputBox and the current date will be added (in the correct format) to the file name through the macro. This will save users the time of having to input the date individually for the 20+ files they run through this formatter each day. (It's very redundant!)

I added the LDate variable, then syntax to try to add the date to the returned value Text.

Sub Quick_Format()
'
' Quick_Format Macro
'

Dim LDate As String

LDate = Format(Date, "yyyy-mm-dd")

'

    Text = InputBox("Enter Item Code")

Range("A1") = Text

    Windows(("" & Text) & "-")("" & LDate)("" & ".xls").Activate
    Sheets("Home").Select

It's not happening! I get an error and when I click debug, the Windows line above is in red. I know I've made a syntax error, but all my attempts to correct it have failed.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Seems you might need the & one both sides of ("" & LDate). Why are you using an item code for your windows index? – mooseman Aug 13 '19 at 19:04
  • Hi Mooseman, I really appreciate the feedback, but I don't understand all of it. Where do you think I need to add the & sign? The item code for the index is just the text box where everyone enters their item code XX000 format, which then pulls all of the data for that item code on that day. Any additional details on your comments would be appreciated! – Erin Flannery Aug 13 '19 at 20:27

1 Answers1

0

I took Mooseman's idea and played around with it some more. This worked!

Changing this line to this:

Windows("" & Text & "-" & "" & LDate & ".xls").Activate

Thank you for the help and platform to seek help! :)