+ Reply to Thread
Results 1 to 2 of 2

Force Entry on UserForm

  1. #1
    Forum Contributor
    Join Date
    04-28-2004
    Location
    Norwich, England
    MS-Off Ver
    2010
    Posts
    119

    Force Entry on UserForm

    Hi all

    I have made a user form and what I want to do is to not let the user close it until they have filled in certain parts of it, so that when they press the submit button there must be

    1) a date selected on the calender

    and

    2) something entered into the textbox

    Ideally some sort of pop up that says please select a date, please enter a value in the textbox

    So far my code for the submit button is:-

    'Data into sheet
    Private Sub CommandButton1_Click()

    Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("Data1")

    'find first empty row in database
    iRow = ws.Cells(Rows.Count, 1) _
    .End(xlUp).Offset(1, 0).Row

    'copy the data to the database
    ws.Cells(iRow, 1).Value = Me.Calendar1.Value
    ws.Cells(iRow, 2).Value = Me.Textbox1.Value

    ws.Cells(iRow, 3).Value = CheckBox1.Value
    ws.Cells(iRow, 4).Value = CheckBox2.Value
    ws.Cells(iRow, 5).Value = CheckBox3.Value
    ws.Cells(iRow, 6).Value = CheckBox4.Value


    Set ws = Worksheets("Sheet2")

    Unload Me

    End Sub
    Also a kind of 'are you sure you have entered everything' confirmation would be handy as they have a fair few checkboxes to choose from

    I'm hoping there might be a nifty little bit of code that I could use for this!

    Many thanks in advance

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Raehippychick,

    Add this macro to your UserForm. It can be expanded to include other controls too.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

+ 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