+ Reply to Thread
Results 1 to 2 of 2

Checkbox to remember data

Hybrid View

minifreak Checkbox to remember data 08-29-2012, 10:40 AM
minifreak Re: Checkbox to remember data 08-30-2012, 05:37 AM
  1. #1
    Registered User
    Join Date
    08-16-2012
    Location
    Almere
    MS-Off Ver
    Excel 2003
    Posts
    48

    Checkbox to remember data

    Dear Forum members,

    Recently I got this working piece of VBA code from this forum that remembers the data that a user has typed in the inputboxes on a userform so when the next userform opens the user doesn't have to type all information again.
    This works great and is very usefull but I want to make a small change to this.
    I made a checkbox in the userforms and now I want the data to be remembered only when the user has selected this checkbox
    If the checkbox is not selected the data should not be remembered.
    I tired to place the checkbox = true code on several places but it's just not working....
    Can someone help me out
    This is the working code that remembers the user's input
    Private Sub CommandButton1_Click()
    Cells(Rows.Count, 1).End(xlUp).Offset(1) = TextBox1.Text
    End Sub
    Private Sub TextBox1_afterupdate()
    txtvalue = TextBox1.Text
    End Sub
    Private Sub UserForm_Initialize()
    TextBox1.Text = txtvalue
    End Sub
    How and where should I add the code so the data is only remembered when checkbox1 is selected ??

  2. #2
    Registered User
    Join Date
    08-16-2012
    Location
    Almere
    MS-Off Ver
    Excel 2003
    Posts
    48

    Re: Checkbox to remember data

    After testing a lot and tried many options with the code, I was able to find the solution
    Below is how I fixed it.
    Private Sub CommandButton1_Click()
    Cells(Rows.Count, 1).End(xlUp).Offset(1) = TextBox1.Text
    If Me.CheckBox1 = True Then
    	txtvalue = TextBox1.Text
       Else
    	txtvalue = ""	
    End Sub
    Private Sub TextBox1_afterupdate()
    txtvalue = TextBox1.Text
    End Sub
    Private Sub UserForm_Initialize()
    TextBox1.Text = txtvalue
    End Sub

+ 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