+ Reply to Thread
Results 1 to 2 of 2

Excel 2007 : Allow blank fields in userform

Hybrid View

  1. #1
    Registered User
    Join Date
    11-14-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    3

    Allow blank fields in userform

    I have a userform to populate 11 goals. When I update, all fields need to be entered. Otherwise, if I leave one of the goals blank the current value is replaced with a blank cell.

    This is the code for my userform:

    Private Sub cmdAdd_Click()
       Dim ws As Worksheet
       Set ws = Worksheets("Dashboard")
       ActiveSheet.Unprotect
       ws.Cells(76, 11).Value = TextBox1.Value
       Debug.Print TextBox2.Value
       ws.Cells(76, 15).Value = TextBox2.Value
       Debug.Print TextBox2.Value
       ws.Cells(76, 18).Value = TextBox3.Value
       Debug.Print TextBox3.Value
       ws.Cells(76, 21).Value = TextBox4.Value
       ws.Cells(76, 24).Value = TextBox5.Value
       ws.Cells(76, 25).Value = TextBox6.Value
       ws.Cells(76, 28).Value = TextBox7.Value
       ws.Cells(76, 31).Value = TextBox8.Value
       ws.Cells(76, 34).Value = TextBox9.Value
       ws.Cells(76, 41).Value = TextBox10.Value
       ws.Cells(76, 45).Value = TextBox11.Value
       Unload Me
       ActiveSheet.Protect
    End Sub
    Private Sub cmdClose_Click()
    Unload Me
    End Sub
    Private Sub UserForm1_Initialize()
     Me.TextBox1.Value = ThisWorkbook.Sheets("Dashboard").Range("A1").Value
    End Sub
    I would like the ability to update a few of the values without replacing the existing values.
    Last edited by kmcarter; 11-28-2011 at 10:24 AM. Reason: did not apply code tag

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Allow blank fields in userform

    Your code is not necessarly unprotecting the dashboard sheet.

    I think you want to amend entries, is that right?

    Start by looking at the DatabaseForm example
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ 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