Results 1 to 10 of 10

Incorporate an Excel Formula in to this Macro

Threaded View

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

    Re: Incorporate an Excel Formula in to this Macro

    Hello BusDriver2,

    I made a few changes to your "OK" command button code. It will now transfer the data from the User Form to the next empty line on your database worksheet. This macro has already been changed in the attached workbook.
    Private Sub cmdOK_Click()
    
      Dim Cell As Range
      Dim Rng As Range
      Dim RngEnd As Range
      Dim Wks As Worksheet
      
        Set Wks = ThisWorkbook.Worksheets("PERMANENT")
        Set Rng = Wks.Range("A3")
        Set RngEnd = Wks.Cells(Rows.Count, Rng.Column).End(xlUp)
        Set Rng = IIf(RngEnd.Row < Rng.Row, Rng, RngEnd.Offset(1, 0))
    
          Set Rng = Rng.Resize(1, 10)
            With Rng
              .Cells(1, 1) = txtName.Value
              .Cells(1, 2) = cboABCD.Value
              .Cells(1, 3) = txtDateArrived.Value
              .Cells(1, 4) = cboABCType.Value
              .Cells(1, 5) = txtDateIssued.Value
              .Cells(1, 6) = txtBoardDate.Value
              .Cells(1, 7) = txtQualifiedDate.Value
              .Cells(1, 8) = cboQualifiedNotQualified.Value
              If chkAAARequired = True Then
                 .Cells(1, 9) = "Yes"
              Else
                 .Cells(1, 9) = "No"
              End If
              If optYELLOW = True Then
                .Cells(1, 10) = "Yellow"
              ElseIf optBLUE = True Then
                .Cells(1, 10) = "Blue"
              ElseIf optORANGE = True Then
                .Cells(1, 10) = "Orange"
              End If
              .Cells(1, 1).Select
            End With
        
    End Sub
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

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