Hi All,
I've been learning as I go, never played with vba before discovering that a userform might make my spreadsheet data entry easier. Now I'm obsessed..!
Problem is this:
Usually it's being used to enter new details into a spreadsheet into the first available blank row, but occasionally I need to retrieve details from sheet to userform based on the invoice number keyed into the userform, using the "CmdRetrieveDetails" button. This works a treat.
I then wish to update details in the sheet and use "CmdUpdateDetails" button to enter them back into the spreadsheet in the row from which they came, but instead they end up in the next blank row still... Can anyone shed any light?
Code for retrieval button and update details button is below:
***There are only 2 values in this list so far, as a test showed that they were still going into the next blank row so I didn't continue!**![]()
Private Sub CmdRetrieveDetails_Click() Dim lastRow Dim invoiceno As String lastRow = Sheets("Invoices").Range("A" & Rows.Count).End(xlUp).Row invoiceno = TxtInvoiceNo.Text For currentrow = 2 To lastRow If Cells(currentrow, 1).Text = invoiceno Then TxtInvoiceNo.Text = Cells(currentrow, 1).Text TxtDate.Text = Cells(currentrow, 2) CmbTransportCode.Text = Cells(currentrow, 39) CmbRunCode.Text = Cells(currentrow, 41) CmbEntryType.Text = Cells(currentrow, 3) ChkCompleted.Value = Cells(currentrow, 61) CmbCustName.Text = Cells(currentrow, 4) ***truncated - many values, all retrieving properly!*** ChkDelivered.Value = Cells(currentrow, 60) ChkInvoiced.Value = Cells(currentrow, 62) ChkPaidCust.Value = Cells(currentrow, 63) ChkBooked.Value = Cells(currentrow, 64) ChkInvoiceReceived.Value = Cells(currentrow, 65) ChkPaidContractor.Value = Cells(currentrow, 66) End If Next currentrow TxtInvoiceNo.SetFocus End Sub --- Private Sub CmdUpdateDetails_Click() Dim invno As String, dat As String invno = TxtInvoiceNo.Text Cells(currentrow, 1).Value = invno dat = TxtDate.Text Cells(currentrow, 2).Value = dat End Sub
There is a global command at the start, which came from the instruction video for this code
Dim currentrow As Long
**
Help please!!! Thanks! Let me know what you need from me...











LinkBack URL
About LinkBacks
Register To Reply

Bookmarks