+ Reply to Thread
Results 1 to 8 of 8

Saving when Cell Completed

  1. #1
    Registered User
    Join Date
    11-05-2004
    Posts
    21

    Saving when Cell Completed

    I am using this code to autosave to a specific server:


    Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    ActiveWorkbook.SaveAs Filename:="\\DTCNAS-ILSP002\Pricing\Builders Choice Completed\" & ActiveSheet.Range("a9")
    End Sub

    Can I modify this so that it saves only when a specific cell is filled?

    Help!!! Thanks, Tawnee.

  2. #2
    Registered User
    Join Date
    03-25-2005
    Posts
    23
    Put an if statement in to check which cell is selected before executing the save as algorithm. If the cell you want is the selected cell, then save as....., if some other cell is selected, then do nothing.

    The macro will always run, but it will not always save (it might do nothing).

  3. #3
    Registered User
    Join Date
    11-05-2004
    Posts
    21
    Can you give me an example?

    Thanks, T.

  4. #4
    Registered User
    Join Date
    03-25-2005
    Posts
    23
    Say you only want it to save when you change cell A1, your code might be:

    ----------------------------------------
    Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

    If ActiveCell.Address = $A$1 Then

    ActiveWorkbook.SaveAs Filename:="\\DTCNAS-ILSP002\Pricing\Builders Choice Completed\" & ActiveSheet.Range("a9")

    Else
    'Do Nothing
    End If

    End Sub
    -----------------------------------

    I have not tested this, let me know if it works, or helps

  5. #5
    Registered User
    Join Date
    03-25-2005
    Posts
    23
    Say you only want it to save when you change cell A1, your code might be:

    ----------------------------------------
    Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

    If ActiveCell.Address = $A$1 Then

    ActiveWorkbook.SaveAs Filename:="\\DTCNAS-ILSP002\Pricing\Builders Choice Completed\" & ActiveSheet.Range("a9")

    Else
    'Do Nothing
    End If

    End Sub
    -----------------------------------

    I have not tested this, let me know if it works, or helps

  6. #6
    Registered User
    Join Date
    11-05-2004
    Posts
    21
    Nope. Doesn't Work. It's a syntax error. This is basically what I keep running into.

    Thanks, T.

  7. #7
    Registered User
    Join Date
    03-25-2005
    Posts
    23
    I tried this and this is what i found:

    The $A$1 needs to be put in quotes ---> "$A$1"

    Even then, this runs whenevr that cell is selcted, not necessarily changed.

  8. #8
    Registered User
    Join Date
    03-25-2005
    Posts
    23
    Here, you must use the Change event and this code should save whenever cell A1 is changed.

    ----------------------------------
    Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address = "$A$1" Then

    ActiveWorkbook.SaveAs Filename:="\\DTCNAS-ILSP002\Pricing\Builders Choice Completed\" & ActiveSheet.Range("a9")

    Else

    'Do Nothing

    End If

    End Sub
    ---------------------------------

    Let me know how it works out.

+ 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