• Use cell value as filename (2003)

    Author
    Topic
    #420553

    I am creating a form that is going to be used to grade exams and while it is easy to save the file using a macro, I have not figured out how to grab the students name from a cell and save the file as that person’s name. Is there a way to do this? Thanks

    Viewing 0 reply threads
    Author
    Replies
    • #952613

      Say that the student name is in cell A1. The following instruction will save the workbook with the name from A1, followed by .xls:

      ActiveWorkbook.SaveAs Range(“A1”)

      • #952720

        I like this, but I need to have it go to a network location. i.e.

        ActiveWorkbook.SaveAs Filename:= _
        “monorailc$<>”, FileFormat:=xlNormal, _

        so I do I place the range at this location?

        • #952722

          Try

          ActiveWorkbook.SaveAs "monorailc$" & Range("A1"), ...

          • #952728

            Thanks Hans, that worked. At first I left it on the A1 cell and I got a runtime error, then when I realized that there was nothing in that cell (oops) and changed it to the one it should be, it became B E A utiful!

            Thanks again

            • #952731

              You could build in a check. Say that you’re using cell B37:

              If Range(“B37”) = “” Then
              Range(“B37”).Select
              MsgBox “Please enter your name!”, vbExclamation
              Else
              ActiveWorkbook.SaveAs “monorailc$” & Range(“B37”), …
              End If

    Viewing 0 reply threads
    Reply To: Reply #952613 in Use cell value as filename (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel