Results 1 to 9 of 9

Data Input using VBA excel forms

Threaded View

  1. #1
    Registered User
    Join Date
    02-16-2014
    Location
    Northampton
    MS-Off Ver
    Excel 2013
    Posts
    14

    Data Input using VBA excel forms

    i have currently made a form using excel see below
    forms.jpg
    i would like to create a code that would use the textbox1 and textbox2 as search criteria
    and then for it to insert the data in textbox3,4 and 5 into required cells

    for example
    textbox 2 to search for the worksheet for requested Vehicle Reg then
    textbox 1 to search for the cell with the exact date already inserted then
    for the data in textbox3 to be written in B4
    for the data in textbox4 to be written in C4
    and for the data in textbox5 to be written in E4

    in any one sheet per vehicle i have 365 days
    and i have a total of about 51 vehicles

    any help would be greatly appriciated

    the code i have already for the ok button is as below,

    Private Sub UserForm_Initialize()
        Dim TodaysDate As String
        
        TodaysDate = Format(Now(), "dd/mm/yyyy")
        
        TextBox1.Value = TodaysDate
    End Sub
    
    Private Sub cmdOK_Click()
        Dim x As Integer
    ' Check user input
        If TextBox2.Text = vbNullString Then
            MsgBox "please enter Vehicle Reg.", vbExclamation, "Vehicle Mileage"
            TextBox2.SetFocus
            Exit Sub
        End If
        If Not IsNumeric(TextBox3.Value) Then
            MsgBox "The Start Mileage Should Be A Figure.", vbExclamation, "Vehicle Mileage"
            TextBox3.SetFocus
            Exit Sub
        End If
        If Not IsNumeric(TextBox4.Value) Then
            MsgBox "The End Mileage Should Be A Figure.", vbExclamation, "Vehicle Mileage"
            TextBox4.SetFocus
            Exit Sub
        End If
        If Not IsNumeric(TextBox5.Value) Then
            MsgBox "The Fuel Should Be A Figure.", vbExclamation, "Vehicle Mileage"
            TextBox5.SetFocus
            Exit Sub
        End If
        
    MsgBox "Data Input Complete"
    ' Clear the form
        For x = 2 To 5
        Me.Controls("TextBox" & x).Value = ""
        Next x
    End Sub
    again any help would be greatly appriciated
    Last edited by Darrel1986; 02-16-2014 at 11:41 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Forms in Excel - How do I link a cell to show me what was selected on an input form?
    By csalcido in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-04-2013, 01:00 PM
  2. Multiple input forms to Master file
    By LeBaron in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-27-2012, 05:05 PM
  3. automating input in forms training matrix
    By ardana in forum Excel General
    Replies: 2
    Last Post: 03-20-2012, 08:27 AM
  4. Input Data using Forms
    By cneff in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 11-09-2011, 01:42 AM
  5. Input Forms
    By LAB2007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-08-2007, 05:16 AM

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