Results 1 to 2 of 2

Thread: File name from multipe cell contents and prefixed filename

  1. #1

    File name from multipe cell contents and prefixed filename

    Good morning

    I'm very new to using VBA.

    I'm currently making a spreadsheet for each of our clients, and to save time, I'm looking to create a VB module to allow information in cells to be used as the filename.

    Currently, I have found the following:

    [vba]Option Explicit

    Sub SaveAsExample()

    Dim FName As String
    Dim FPath As String

    FPath = "C:"
    FName = Sheets("Sheet1").Range("C10").Text
    ThisWorkbook.SaveAs FileName:=FPath & "\" & FName

    End Sub
    [/vba]


    Ideally, I would like it to present:

    C11 C10 - Individual Learning Plan 0910

    I would like it to allow me to use at least 2 cells in the Range for the client ref number and also their name. I would also like a prefixed filename after this.

    Any assistance would be greatly appreciated

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,446
    Location
    [vba]

    Sub SaveAsExample()

    Dim FName As String
    Dim FPath As String

    FPath = "C:\"
    FName = Sheets("Sheet1").Range("C10").Text & " " & Sheets("Sheet1").Range("C11").Text
    ThisWorkbook.SaveAs FileName:=FPath & FName & Format(Date,"ddmm")
    [/vba]

    End Sub
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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