VBA Excel UserForm "Update" Current Record

  • Hello,

    Fairly new at VBA and I'm stuck!
    I've created a form where an event can be entered.
    I also want the user to be able to update the event, if needed.
    I figured out how to search on the event and re-fill the form, but I'm unable to figure out the code to "update" the information when/if changed.
    I've been trolling excel boards for days borrowing code and none of it seems to be working.

    I've attached a representative example of the file.

    Any & all help would be greatly appreciated!

  • Re: VBA Excel UserForm "Update" Current Record

    Hi Bette

    Your UPDATE EVENT CODE button is firing other Code Change Events and you need to prevent those from firing. Updated Code is in the attached.

    In Module3 add this line of Code...

    Public Flag         As Boolean   '<---Add this Line of Code
    Sub Button2_Click()
    End Sub

    In Module HOSTED_EVENTS add the three indicated lines of Code to Private Sub UpdateEvent_Click...

    Then in Private Sub SearchEventName_Change() add the indicated Line of Code...

    [Private Sub SearchEventName_Change()
       Dim ws           As Worksheet
       Dim lastrow      As Long
       Dim C            As Range
       If Flag = True Then Exit Sub  '<---Add this Line of Code
       Set ws = Worksheets("DATA")
       With ws
  • Re: VBA Excel UserForm &quot;Update&quot; Current Record

    You are my hero! Those modifications worked beautifully!
    Thank you very much!!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!