+ Reply to Thread
Results 1 to 6 of 6

Auto-save a new file with data from 3 cells

Hybrid View

Glio Auto-save a new file with... 12-02-2007, 03:05 PM
VBA Noob Try changing name ranges to... 12-02-2007, 03:10 PM
Glio VB Noob Thanks for your... 12-02-2007, 05:44 PM
VBA Noob Forgot the format .xls also... 12-02-2007, 06:06 PM
Glio Auto-save a new file with... 12-02-2007, 07:27 PM
VBA Noob Your welcome VBA Noob 12-02-2007, 07:29 PM
  1. #1
    Forum Contributor
    Join Date
    11-13-2007
    Location
    Petersfield, Hampshire, UK
    MS-Off Ver
    MS Office for Mac ver 16
    Posts
    135

    Auto-save a new file with data from 3 cells

    I would like to have a template .xlt file which, when three cells have been completed (and they must be completed!) automatically saves the .xls file in the one folder with the file name made up of the concatenated cells data.

    This is in part linked to this 'Prevent Save unless cells are complete' thread
    http://www.excelforum.com/showthread.php?t=625297

    This would then ensure that my users would always get the file naming protocol correct!

    The three cells have been named as ExIncOp, Name and StartDate. StartDate has been formatted to appear as dd-mmm-yy.

    I have put the formula
    =(LEFT(ExIncOp,2) & " " & Name &  " " & StartDate)
    in one cell which produces what I want except that the date is no longer formatted dd-mmm-yy and then recorded a macro to save the file

    Sub SaveFile()
    
    ' SaveFile Macro
    '
        Range("M6").Select
        Selection.Copy
        Application.CutCopyMode = False
        ActiveWorkbook.SaveAs Filename:= _
            "H:\........\Ex Test 39417.xls", FileFormat:=xlExcel8 _
            , Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
            CreateBackup:=False
    End Sub
    which unfortunately did not allow me to paste what I had copied from the concatenated cell into the file name field.

    Is this possible?
    Geoff Culbertson
    Petersfield, UK

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Try changing name ranges to e.g
    Range("ExIncOp").value
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Contributor
    Join Date
    11-13-2007
    Location
    Petersfield, Hampshire, UK
    MS-Off Ver
    MS Office for Mac ver 16
    Posts
    135
    VB Noob

    Thanks for your response. I have tried Ranges as you suggested

    Sub SaveFile()
    ' SaveFile Macro
    '
        ActiveWorkbook.SaveAs Filename:= _
            "H:\ ...path...\" & Range("ExIncOp").Value & " " & Range("Name").Value _
            & " " & Range("StartDate").Value, FileFormat:=xlExcel8 _
            , Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
            CreateBackup:=False
    End Sub
    but it now gives me a 400 warning box, which I think means the form is already in use

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Forgot the format .xls also you can't use / when naming workbooks
    try something like

    Dim Dt As Date
    Dt = Range("StartDate").Value
    
        ActiveWorkbook.SaveAs Filename:= _
            "C:\" & Range("ExIncOp").Value & " " & Range("Name").Value _
            & " " & Format(Dt, "dd-mm-yy") & ".xls", FileFormat:=xlNormal
    Change path to your path

    VBA Noob
    Last edited by VBA Noob; 12-02-2007 at 07:28 PM.

  5. #5
    Forum Contributor
    Join Date
    11-13-2007
    Location
    Petersfield, Hampshire, UK
    MS-Off Ver
    MS Office for Mac ver 16
    Posts
    135

    Smile Auto-save a new file with data from 3 cells

    Thanks a lot VB Noob,

    You pointed me to my final effort, which works exactly as I wanted i.e.

    Sub SaveFile()
    '
    ' SaveFile Macro
    '
    Dim Dt As Date
    Dim Ex As String
    
    Dt = Range("StartDate").Value
    Ex = Left(ExIncOp, 2)
    '
        ActiveWorkbook.SaveAs Filename:= _
            "H:\...Path...\" & "Ex" & " " & Range("Name").Value _
            & " " & Format(Dt, "dd-mmm-yy") & ".xls", FileFormat:=xlNormal
    
    End Sub
    Thanks again

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Your welcome

    VBA Noob

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1