Consulting

Results 1 to 2 of 2

Thread: Trying to place values in a sheet

  1. #1
    VBAX Regular MUSASHI's Avatar
    Joined
    Oct 2004
    Location
    Corpus Christi, Texas (Very South)
    Posts
    44

    Trying to place values in a sheet

    I zipped up a lil file...its messy, not cleaned up yet, but a "working" copy...

    EDITED

    Revised, can somebody look at my frm_ViewEmp userform code. The data selected each time from the list on that form will vary each time....may be 1 or 2 items may be as many as 6-7 items. I tried to emulate the code from the other userform, but obviously missing something...

    Sorry to be persistent, last major hump.

    Thx

  2. #2
    VBAX Regular MUSASHI's Avatar
    Joined
    Oct 2004
    Location
    Corpus Christi, Texas (Very South)
    Posts
    44
    Andy form Oz Board helped me out with this code


    Private Sub cb_EmpExit_Click() 
        Dim LastRow As Long 
        Dim intCol As Integer 
        Dim intIndex As Integer 
         'make sure employee number is entered
        Select Case tbTrainDate.Text 
        Case Is = "Required!" 
            MsgBox "Sorry, but you must enter a date from the Calendar! " 
            Exit Sub 
        Case Else 
             'do nothing
        End Select 
    With Worksheets("Records") 
            LastRow = .Range("A65536").End(xlUp).Row + 1 
            .Cells(LastRow, 1).Value = tbTrainDate.Value 
    ' Store values from listbox1 columns
            .Cells(LastRow, 2).Value = ListBox1.List(ListBox1.ListIndex, 0) 
            .Cells(LastRow, 3).Value = ListBox1.List(ListBox1.ListIndex, 1) 
            .Cells(LastRow, 4).Value = ListBox1.List(ListBox1.ListIndex, 2) 
    ' store option button choice
            If Me.obMedical Then .Cells(LastRow, 5) = 1 
            If Me.obCSC Then .Cells(LastRow, 5) = 2 
            If Me.obCraft Then .Cells(LastRow, 5) = 3 
            If Me.obEquipment Then .Cells(LastRow, 5) = 4 
    ' store selected items from listbox2
            intCol = 6 
            For intIndex = 0 To ListBox2.ListCount - 1 
                If ListBox2.Selected(intIndex) Then 
                    .Cells(LastRow, intCol).Value = ListBox2.List(intIndex) 
                    intCol = intCol + 1 
                End If 
            Next 
        End With 
        Unload Me 
    End Sub
    fyi,

    Thanks
    Mus

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •