Saving form data to worksheet goes in row ABOVE

I have a user form that accepts changes.  When the user hits save, the data should be saved in the row that appears on the form via the VBA code.  Say data is sourced in Row 11 and this row number is what is reflected on the form.  When the user saves changes, all the data should go back to the proper field on the form in Row 11, but it goes into row 10!  I checked and it seems c onsistent, the data is saved in the row above the row reflected on the form.  
Private Sub SaveData()
'Save changed data to Settings worksheet
With ThisWorkbook.Worksheets("Settings")
    .Unprotect Password:=s_PSWD
          With .Rows(Me.txtRowNumber)
                .Cells(0, 1).Value = Me.txtAddedBy.Value
                .Cells(0, 2).Value = Me.txtAddDate.Value
                .Cells(0, 3).Value = "Yes"
                .Cells(0, 4).Value = Me.txtClosedChangedBy.Value
                .Cells(0, 5).Value = Me.txtCloseChangeDate.Value
                .Cells(0, 6).Value = Me.txtPortfolioCode.Value
                .Cells(0, 7).Value = Me.txtPortfolioName.Value
                .Cells(0, 8).Value = Me.txtURLSectorSummary.Value
                .Cells(0, 9).Value = Me.txtURLSectorDetail.Value
                .Cells(0, 10).Value = Me.txtURLRatingSummary.Value
                .Cells(0, 11).Value = Me.txtURLRatingDetail.Value
         End With
    .Protect Password:=s_PSWD
End With
'Reset form for next data set changes
Call ClearControls
MsgBox "Data has been saved", vbOKOnly
    Exit Sub
        MsgBox Err.Number & " Description: " & Err.Description
        Resume Exit_ErrorHandler
End Sub

Open in new window

Sandra SmithRetiredAsked:
Who is Participating?
Rory ArchibaldCommented:
No, you are telling it the correct start cell, but Cells(0,1) is the cell above that cell. Perhaps you are confusing it with .Offset(0,1) which would be the cell in the same row but one column across?
Might be your cells notation. Does this work?

.Cells(1, 1).Value = Me.txtAddedBy.Value
Rory ArchibaldCommented:
Change the zeroes in .Cells(0, 1) etc to 1 and you should be fine.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Sandra SmithRetiredAuthor Commented:
I am looking at it and maybe it is simply that I am referring to the row number, but not telling it to start with cell A11?  that is, if the .Rows(Me.txtRowNumber) = 11, I think I am missing the point in that I need to now tell it the starting cell is A11?  You both are correct in that Cells(1,1) will work, but I am wondering that myproblem is I simply am not telling it which cell to actually start with?
If txtRowNumber=11 then Rows(11).Cells(1,1) is A11.
Sandra SmithRetiredAuthor Commented:
Rorya, yes, I think I am getting confused.  I was assuming zero-based starting point and now this does make sense.  Thank you both!  Am splitting points as you both answered the question.  And I appreciate the lesson.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.