Hello,
I have a sheet containing data which I have entered. Every now and then I need to update a certain record in a row. I have created the following code to update the data; however, every time I execute the macro, instead of update the existing data it creates a new one on a row row. I don't know how else to get it to work. Whatever help you can provide is greatly appreciated.
Private Sub CmdUpdate_Click()
ActiveSheet.Unprotect Password:="3833"
Dim myitem As String, itemtype As String
Dim center As String, entry As String
Dim issued As String, due As String
Dim amount As String, collection As String
Dim fee As String, source As String
Dim cbbfee As String, institution As String
Dim payor As String, payee As String
Dim instruction As String, paidreturn As String
Dim prdate As String, unpaidreason As String
Dim amtpaid As String, sor As String
Dim Sordate As String, deposit As String
Dim paytype As String, credacct As String, payno As String
myitem = txtItem.Text
Cells(currentrow, 17).Value = myitem
itemtype = txtType.Text
Cells(currentrow, 21).Value = itemtype
center = txtCenter.Text
Cells(currentrow, 31).Value = center
entry = txtEdate.Text
Cells(currentrow, 22).Value = entry
issued = txtIdate.Text
Cells(currentrow, 23).Value = issued
due = txtDdate.Text
Cells(currentrow, 24).Value = due
amount = txtIamt.Text
Cells(currentrow, 25).Value = amount
collection = txtCreason.Text
Cells(currentrow, 38).Value = collection
institution = txtInst.Text
Cells(currentrow, 18).Value = institution
payor = txtPayor.Text
Cells(currentrow, 19).Value = payor
payee = txtPayee.Text
Cells(currentrow, 20).Value = payee
instruction = txtSinstruct.Text
Cells(currentrow, 30).Value = instruction
paidreturn = txtPR.Text
Cells(currentrow, 26).Value = paidreturn
prdate = txtPRdate.Text
Cells(currentrow, 27).Value = prdate
unpaidreason = txtRreason.Text
Cells(currentrow, 34).Value = unpaidreason
amtpaid = txtAmtpd.Text
Cells(currentrow, 28).Value = amtpaid
sor = txtSor.Text
Cells(currentrow, 34).Value = sor
Sordate = txtSorDate.Text
Cells(currentrow, 36).Value = Sordate
deposit = txtSorDep.Text
Cells(currentrow, 37).Value = deposit
paytype = txtPaytype.Text
Cells(currentrow, 29).Value = paytype
credacct = txtAcct.Text
Cells(currentrow, 32).Value = credacct
payno = TxtNo.Text
Cells(currentrow, 33).Value = payno
ActiveSheet.Protect Password:="3833"
End Sub
I have a sheet containing data which I have entered. Every now and then I need to update a certain record in a row. I have created the following code to update the data; however, every time I execute the macro, instead of update the existing data it creates a new one on a row row. I don't know how else to get it to work. Whatever help you can provide is greatly appreciated.
Private Sub CmdUpdate_Click()
ActiveSheet.Unprotect Password:="3833"
Dim myitem As String, itemtype As String
Dim center As String, entry As String
Dim issued As String, due As String
Dim amount As String, collection As String
Dim fee As String, source As String
Dim cbbfee As String, institution As String
Dim payor As String, payee As String
Dim instruction As String, paidreturn As String
Dim prdate As String, unpaidreason As String
Dim amtpaid As String, sor As String
Dim Sordate As String, deposit As String
Dim paytype As String, credacct As String, payno As String
myitem = txtItem.Text
Cells(currentrow, 17).Value = myitem
itemtype = txtType.Text
Cells(currentrow, 21).Value = itemtype
center = txtCenter.Text
Cells(currentrow, 31).Value = center
entry = txtEdate.Text
Cells(currentrow, 22).Value = entry
issued = txtIdate.Text
Cells(currentrow, 23).Value = issued
due = txtDdate.Text
Cells(currentrow, 24).Value = due
amount = txtIamt.Text
Cells(currentrow, 25).Value = amount
collection = txtCreason.Text
Cells(currentrow, 38).Value = collection
institution = txtInst.Text
Cells(currentrow, 18).Value = institution
payor = txtPayor.Text
Cells(currentrow, 19).Value = payor
payee = txtPayee.Text
Cells(currentrow, 20).Value = payee
instruction = txtSinstruct.Text
Cells(currentrow, 30).Value = instruction
paidreturn = txtPR.Text
Cells(currentrow, 26).Value = paidreturn
prdate = txtPRdate.Text
Cells(currentrow, 27).Value = prdate
unpaidreason = txtRreason.Text
Cells(currentrow, 34).Value = unpaidreason
amtpaid = txtAmtpd.Text
Cells(currentrow, 28).Value = amtpaid
sor = txtSor.Text
Cells(currentrow, 34).Value = sor
Sordate = txtSorDate.Text
Cells(currentrow, 36).Value = Sordate
deposit = txtSorDep.Text
Cells(currentrow, 37).Value = deposit
paytype = txtPaytype.Text
Cells(currentrow, 29).Value = paytype
credacct = txtAcct.Text
Cells(currentrow, 32).Value = credacct
payno = TxtNo.Text
Cells(currentrow, 33).Value = payno
ActiveSheet.Protect Password:="3833"
End Sub