Hi,
I'm inserting content from a userform into an excel sheet. The sheet is locked, but I want to be able to change the last row that has been inserted. It's probably the Range that I'm not defining right, but hopefully someone can help me out. Thanks in advance for your help and effort.
Private Sub cmbIndberet_Click()
Dim ws As Worksheet, RaekkeNr As Integer, lrow As Long
Set ws = Worksheets("Gbrugsvare Saelger")
With ws
.Unprotect
lrow = .Cells(Rows.Count, "F").End(xlUp).Row
RaekkeNr = .Cells(1, 1).CurrentRegion.Rows.Count + 1
.Cells(RaekkeNr, 1).Value = txtVareID.Text
.Cells(RaekkeNr, 2).Value = Date
.Cells(RaekkeNr, 3).Value = txtSalgspris.Text
.Cells(RaekkeNr, 4).Value = txtFakturanummer.Text
.Cells(RaekkeNr, 5).Value = cbSaelger.Text
.Columns.AutoFit
.Range("A1", lrow - 1).Protect
End With
txtVareID.Value = ""
txtFakturanummer.Value = ""
txtSalgspris.Value = ""
End Sub
Bookmarks