Auto copy data to another sheet after modification

SamarthSalunkhe

Board Regular
Joined
Jun 14, 2021
Messages
103
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

I'm using the below user form to add data and to edit data. I have Encrypted Database Sheet to avoid unwanted modification in files and to add data and edit data purposes I have created a user form.

In addition in this form, I want one code to copy data which is selected for modification because I don't want to lose previous data from the record.

below is code I am using for edit click butten.

VBA Code:
Private Sub cmdEdit_Click()
    
    If Selected_List = 0 Then
    
        MsgBox "No row is selected.", vbOKOnly + vbInformation, "Edit"
        
        Exit Sub
    
    End If
    
    'Code to update the value to respective controls
    
    Me.txtRowNumber.Value = Application.WorksheetFunction.Match(Me.lstDatabase.List(Me.lstDatabase.ListIndex, 0), _
    ThisWorkbook.Sheets("Database").Range("A:A"), 0)
    
    Me.txtRemark.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 1)
    
    Me.txtTally.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 2)
    
    Me.txtName.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 3)
    
    Me.txtAccount.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 4)
    
    Me.txtIFSC.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 5)
    
    Me.txtBank.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 6)
    
    
    MsgBox "Please make the required changes and click on 'Save' button to update.", vbOKOnly + vbInformation, "Edit"
    
End Sub

1640148420184.png
 

Attachments

  • 1640147895747.png
    1640147895747.png
    19.2 KB · Views: 13

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top