Excel 2003 using multiple cell refernces as filename?

Hi,
I am very new to VBA so excuse my ignorance.

Is it possible to save a file using several different cell references as its file name?

I have written a macro that creates a new workbook which pulls data from another workbook. I want to save this workbook using references from three different cells as the file name.

ie
cell A1 = Joe Bloggs
cell A2 = Ireland
Cell A3 = 001

Is it possible for me to save this file as A1_A2_A3.xls
Example: Joe Bloggs_Ireland_001

Any help would be much appreciated
Thanks

Comments

  • certainly, here's one way-


    [code]
    Sub Macro1()
    '
    ' Macro1 Macro
    ' Macro recorded 08/14/2008 by
    '
    ' Keyboard Shortcut: Ctrl+q
    '

    Dim myName As String
    myName = "D:" 'drive-letter
    myName = myName & Application.Cells(1, 1) & "_" 'cell A1
    myName = myName & Application.Cells(2, 1) & "_" 'cell A2
    myName = myName & Application.Cells(3, 1) & ".xls" 'cell A3

    ActiveWorkbook.SaveAs Filename:=myName, FileFormat:=xlNormal, _
    Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
    CreateBackup:=False
    End Sub
    [/code]
  • : certainly, here's one way-
    :
    :
    : [code]:
    : Sub Macro1()
    : '
    : ' Macro1 Macro
    : ' Macro recorded 08/14/2008 by
    : '
    : ' Keyboard Shortcut: Ctrl+q
    : '
    :
    : Dim myName As String
    : myName = "D:" 'drive-letter
    : myName = myName & Application.Cells(1, 1) & "_" 'cell A1
    : myName = myName & Application.Cells(2, 1) & "_" 'cell A2
    : myName = myName & Application.Cells(3, 1) & ".xls" 'cell A3
    :
    : ActiveWorkbook.SaveAs Filename:=myName, FileFormat:=xlNormal, _
    : Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
    : CreateBackup:=False
    : End Sub
    : [/code]:


    Cheers mate thanks for the help. Works a treat!
    Thanks
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories