Results 1 to 2 of 2

insert row in ws by alphabetical listing by column

Threaded View

  1. #1
    Registered User
    Join Date
    01-05-2014
    Location
    London, England
    MS-Off Ver
    Excel 20010
    Posts
    28

    insert row in ws by alphabetical listing by column

    I have made an excel form and it works of a fashion but I want to insert a line into worksheet Driver Training Log alphabetically by column B then colum C. Row 1 is the column titles. Any guidance will be appreciated My code is;
    #
    Private Sub Cmdbutton_add_Click()
    Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("Driver Training Log")

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

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

    'copy the data to the database
    ws.Cells(iRow, 2).Value = Me.textbox_terminal.Value
    ws.Cells(iRow, 3).Value = Me.textbox_lastname.Value
    ws.Cells(iRow, 5).Value = Me.textbox_firstname.Value
    ws.Cells(iRow, 6).Value = Me.textbox_contractstatus.Value
    ws.Cells(iRow, 7).Value = Me.textbox_group.Value
    ws.Cells(iRow, 8).Value = Me.textbox_licenceexp.Value
    ws.Cells(iRow, 9).Value = Me.textbox_adrexp.Value
    ws.Cells(iRow, 10).Value = Me.textbox_aapractical.Value
    ws.Cells(iRow, 11).Value = Me.textbox_aatheory.Value
    ws.Cells(iRow, 12).Value = Me.textbox_drivercoachaa.Value

    MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
    'clear the data
    Me.textbox_terminal.Value = ""
    Me.textbox_lastname.Value = ""
    Me.textbox_firstname.Value = ""
    Me.textbox_contractstatus.Value = ""
    Me.textbox_group.Value = ""
    Me.textbox_licenceexp.Value = ""
    Me.textbox_adrexp.Value = ""
    Me.textbox_aatheory.Value = ""
    Me.textbox_aapractical.Value = ""
    Me.textbox_drivercoachaa.Value = ""
    Me.textbox_lastname.SetFocus


    End Sub

    Private Sub Cmdbutton_close_Click()
    Unload Me
    End Sub

    Private Sub textbox_aapractical_Change()

    End Sub

    Private Sub textbox_aatheory_Change()

    End Sub

    Private Sub textbox_terminal_Change()

    End Sub

    Private Sub UserForm_Click()

    End Sub
    #
    Last edited by bob07904; 01-05-2014 at 08:53 AM. Reason: Forum Rule #3

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA - row insert in alphabetical order
    By dribble in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-19-2013, 07:45 PM
  2. Macro To Insert Letters in Alphabetical Order ,
    By donnydorko in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-24-2009, 11:09 PM
  3. Making column in excel alphabetical
    By boe in forum Excel General
    Replies: 2
    Last Post: 01-02-2006, 07:20 PM
  4. [SOLVED] Why are my column headings numerical instead of alphabetical?
    By raken in forum Excel General
    Replies: 1
    Last Post: 09-09-2005, 12:05 AM
  5. [SOLVED] alphabetical listing reqd
    By Deepak in forum Excel General
    Replies: 1
    Last Post: 02-16-2005, 01:59 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