Consulting

Results 1 to 8 of 8

Thread: save userform and continue later

  1. #1

    save userform and continue later

    wondering if there is a code to save the values/data in a UserForm so that the user can close the workbook and then open back up and complete at a later time?
    Thanks!

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    You could add a button to write code to a temporary worksheet. On opening the userform, Initialize can check for its existence, and if found, write the values to the form and delete the temporary sheet.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Quote Originally Posted by mdmackillop
    You could add a button to write code to a temporary worksheet. On opening the userform, Initialize can check for its existence, and if found, write the values to the form and delete the temporary sheet.
    how would this be done

  4. #4
    VBAX Mentor Brandtrock's Avatar
    Joined
    Jun 2004
    Location
    Titonka, IA
    Posts
    399
    Location
    You could also set the Tag property of any control with a value entered equal to that value and fill it back in when the form gets activated again.

    Regards,
    Brandtrock




  5. #5
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    Try this ...

    Charlize

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Here is a simple example that saves all of the controls in a form on closedown

    [vba]

    Private Sub UserForm_Terminate()
    Dim oSaved As Worksheet
    Dim oCtl As Control
    Dim i As Long
    On Error Resume Next
    Set oSaved = Worksheets("SaveUF")
    On Error GoTo 0
    If oSaved Is Nothing Then
    Worksheets.Add.Name = "SaveUF"
    Set oSaved = Worksheets("SaveUF")
    End If
    oSaved.Cells.ClearContents

    With Me
    i = 1
    For Each oCtl In .Controls
    oSaved.Cells(i, "A").Value = oCtl.Name
    On Error Resume Next
    oSaved.Cells(i, "B").Value = oCtl.Caption
    oSaved.Cells(i, "C").Value = oCtl.Value
    On Error GoTo 0
    i = i + 1
    Next oCtl
    End With
    End Sub
    [/vba]

  7. #7
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Is there any reason that custom document properties couldn't be used for this?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    No there isn't; as there is no reason Excel defined names COULDN'T; as there is no reason the registry COULDN'T; as there is no reason .ini files COULDN'T; as there is no reason text files COULDN'T; as there is no reason ...

    They are all just receptacles for the information.

Posting Permissions

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