Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: VBA code needed

  1. #1
    Guest

    Default

    Hi,
    i made some excel sheet that i need to save often (after changes) under another name, and that name always depends on cell A1 and cell B3. So i've thought to make some vba button assigned as let us say SAVE, which will save document like -.xls when clicked. I know how to draw button (heh, like using tools is hard ) but what code should i enter for that button so that it saves my document under name as described?

    ty very much

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    If your cells A1 and B3 are on the first worksheet and the command button has the default name, the following will save it as a combination of those cells, with a space in the middle, into the current directory. Hope this is what you meant : -

    Private Sub CommandButton1_Click()

    On Error GoTo ErrTrap

    ThisWorkbook.SaveAs Worksheets(1).Range("A1") & " " & Worksheets(1).Range("B3")

    Exit Sub

    ErrTrap:
    MsgBox "Unable to save under that filename"

    End Sub


    [ This Message was edited by: Mudface on 2002-03-04 12:14 ]

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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