Results 1 to 2 of 2

Thread: Update my existing macro to be able to update and delete

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Oct 2022
    Posts
    1
    Rep Power
    0

    Update my existing macro to be able to update and delete

    Hi.

    I have a VBA macro that I have been using to update a roster with planned and unplanned leave.

    I have it cross posted here: https://chandoo.org/forum/threads/up...-delete.49277/
    HTML Code:
    https://chandoo.org/forum/threads/update-my-existing-macro-to-be-able-to-update-and-delete.49277/

    What I was hoping to do was to have the ability within the same code or a separate code to:
    - Delete requests that are no longer required
    or
    - Change the type of planned or unplanned leave

    Here is the script that I use to add planned and unplanned leave, any help in making the above changes I would really appreciate.


    Code:
    Private Sub cbbAdd_Click()
    
    answer = MsgBox("Are you sure you want make the changes?", vbYesNo + vbQuestion, "Add Record")
    If answer = vbYes Then
    
    Dim LeaveDate As Date
    LeaveDate = txtLeaveStart.Text
    Dim LeaveEnd As Date
    LeaveEnd = txtLeaveEnd.Text
    Dim FirstName As String
    FirstName = FirstNameCombo.Text
    Dim LeaveType As String
    LeaveType = LeaveTypeCombo.Text
    Dim DateAdded As Date
    Dim wsh As Worksheet
    Set wsh = ThisWorkbook.Worksheets("Leave")
    Set tbl = wsh.ListObjects("tblEmployees")
    Dim lRow As ListRow
    For LeaveDate = CDate(txtLeaveStart.Text) To CDate(txtLeaveEnd.Text)
    
    Set lRow = tbl.ListRows.Add
    With lRow
    .Range(1) = LeaveDate
    .Range(2) = FirstName
    .Range(3) = LeaveType
    .Range(5) = Now()
    
    End With
    Next
    End If
    
    MsgBox "Complete"
    
    End Sub
    Last edited by DocAElstein; 10-08-2022 at 05:15 PM. Reason: cross post link

Similar Threads

  1. Macro to open and update several workbooks
    By Flupsie in forum Excel Help
    Replies: 0
    Last Post: 08-07-2014, 08:51 AM
  2. Replies: 4
    Last Post: 02-27-2014, 08:49 PM
  3. Replies: 2
    Last Post: 05-30-2013, 07:28 PM
  4. How to Update Daily Log In Another Sheet
    By Rajesh Kr Joshi in forum Excel Help
    Replies: 6
    Last Post: 04-06-2013, 01:47 PM
  5. Replies: 2
    Last Post: 11-17-2011, 07:49 PM

Tags for this Thread

Posting Permissions

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