Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Jun 2002
    Location
    Westlake, Ohio, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Use cell value as filename (2003)

    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
    ...

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Use cell value as filename (2003)

    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")

  3. #3
    Lounger
    Join Date
    Jun 2002
    Location
    Westlake, Ohio, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use cell value as filename (2003)

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

    ActiveWorkbook.SaveAs Filename:= _
    "monorailc$<<filename>>", FileFormat:=xlNormal, _

    so I do I place the range at this location?
    ...

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Use cell value as filename (2003)

    Try

    <code>ActiveWorkbook.SaveAs "monorailc$" & Range("A1"), ...</code>

  5. #5
    Lounger
    Join Date
    Jun 2002
    Location
    Westlake, Ohio, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use cell value as filename (2003)

    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
    ...

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Use cell value as filename (2003)

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •