+ Reply to Thread
Results 1 to 1 of 1

VBA coding assistance.

  1. #1
    Registered User
    Join Date
    02-07-2017
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    0

    VBA coding assistance.

    Hi Guys,

    I have created an excel form to load on to a worksheet I have. I am having trouble with the code. I have checked it many times and I may be missing something simple.


    I have attached the code the line which is causing an issue is the 2nd part which begins 'find first empty row in the database

    Private Sub Cmdbutton_data_Click()
    Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("Mastersheet")

    'find first empty row in database
    iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1[/B]


    'check for a Name number
    If Trim(Me.frm_pupil.Value) = "" Then
    Me.frm_pupil.SetFocus
    MsgBox "Please complete the form"
    Exit Sub
    End If

    'copy the data to the database
    ws.Cells(iRow, 1).Value = Me.frm_pupil.Value
    ws.Cells(iRow, 2).Value = Me.frm_time.Value
    ws.Cells(iRow, 3).Value = Me.frm_staff.Value
    ws.Cells(iRow, 4).Value = Me.frm_date.Value
    ws.Cells(iRow, 5).Value = Me.frm_intreason.Value
    ws.Cells(iRow, 6).Value = Me.frm_eventsprior.Value
    ws.Cells(iRow, 7).Value = Me.frm_behaviour.Value
    ws.Cells(iRow, 8).Value = Me.frm_routine.Value
    ws.Cells(iRow, 9).Value = Me.frm_risk.Value
    ws.Cells(iRow, 10).Value = Me.frm_bestaction.Value
    ws.Cells(iRow, 11).Value = Me.frm_restrainttype.Value
    ws.Cells(iRow, 12).Value = Me.frm_bestaction.Value
    ws.Cells(iRow, 13).Value = Me.frm_post.Value

    MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
    'clear the data
    Me.frm_pupil.Value = ""
    Me.frm_time.Value = ""
    Me.frm_staff.Value = ""
    Me.frm_date.Value = ""
    Me.frm_intreason.Value = ""
    Me.frm_eventsprior.Value = ""
    Me.frm_behaviour.Value = ""
    Me.frm_routine.Value = ""
    Me.frm_risk.Value = ""
    Me.frm_bestaction.Value = ""
    Me.frm_restrainttype.Value = ""
    Me.frm_bestaction.Value = ""
    Me.frm_post.Value = ""
    Me.frm_pupil.SetFocus
    End Sub

    Private Sub cmdbutton_cancel_Click()
    Unload Me
    End Sub


    Private Sub frm_pupil_Change()

    End Sub

    If anyone is able to give me any pointers I would appreciate it?

    Thanks

    John

  2. #2
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: VBA coding assistance.

    Please Login or Register  to view this content.
    Teach me Excel VBA

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Coding assistance
    By hometown_ground in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-14-2016, 06:22 AM
  2. [SOLVED] Vba assistance with coding for ListBox population from textBoxes
    By sintek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2016, 06:26 AM
  3. [SOLVED] Runtime error 1004 VBA Coding assistance
    By sintek in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-11-2016, 02:31 AM
  4. Coding assistance!
    By unistudent1990 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-20-2014, 02:23 AM
  5. [SOLVED] Assistance with search coding
    By Velmortis in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-27-2013, 01:38 PM
  6. [SOLVED] Excel 2007 : If Then Else and/or Select Case Coding Assistance
    By MrSir in forum Excel General
    Replies: 3
    Last Post: 07-05-2012, 12:48 PM
  7. Assistance with macro coding
    By stellakebab in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-26-2007, 04:41 AM

Tags for this Thread

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