Results 1 to 7 of 7

Protecting row.count - 1 when inserting from userform

Threaded View

  1. #1
    Forum Contributor timtim89's Avatar
    Join Date
    01-05-2012
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    141

    Protecting row.count - 1 when inserting from userform

    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
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1