alexdurc09
New Member
- Joined
- Sep 21, 2018
- Messages
- 17
Hello all,
I have the code below which captures information inputted onto a user form and pastes it into a spreadsheet which is locked.
I have a need to be able to still keep the spreadsheet locked but to allow the use of the autofilter function. I have searched Google but so far have been unable to get it to work. Please can anyone help?
I have the code below which captures information inputted onto a user form and pastes it into a spreadsheet which is locked.
I have a need to be able to still keep the spreadsheet locked but to allow the use of the autofilter function. I have searched Google but so far have been unable to get it to work. Please can anyone help?
Code:
Private Sub UpdateRecord_Click()
Sheet1.Unprotect Password:="manlog"
Sheet7.Unprotect Password:="manlog"
If Me.Reg1.Value = "" Then
MsgBox "Container Number Can Not be Blank!",vbExclamation, "Container Number"
Exit Sub
End If
CONTAINERNUMBER = Me.Reg1.Value
Sheets("Containers").Select
Dim rowselect As Double
Dim findrow As Range
Dim lastRowHistory As Long
Set findrow =Worksheets("Containers").Range("A:A").Find(what:=Me.Reg1.Value,LookIn:=xlValues)
rowselect = findrow.Row
'move current record to history
lastRowHistory = Worksheets("HistoricalRecords").Cells(Rows.Count, "A").End(xlUp).Row
lastRowHistory = lastRowHistory + 1
Rows(rowselect).Select
Selection.Copy
Sheets("Historical Records").Select
Rows(lastRowHistory).Select
ActiveSheet.Paste
Sheets("Containers").Select
'rowselect = Me.Reg1.Text
'rowselect = rowselect + 1
Rows(rowselect).Select
Cells(rowselect, 2) = Me.Reg2.Text
Cells(rowselect, 3) = Me.Reg3.Text
Cells(rowselect, 4) = Me.Reg4.Text
Cells(rowselect, 5) = Me.Reg5.Text
Cells(rowselect, 6) = Me.Reg6.Text
Cells(rowselect, 7) = Me.Reg7.Text
Cells(rowselect, 8) = Me.Reg8.Text
Cells(rowselect, 9) = Me.Reg9.Text
Cells(rowselect, 10) = Me.Reg10.Text
Cells(rowselect, 11) = Me.Reg11.Text
Cells(rowselect, 12) = Me.Reg12.Text
Cells(rowselect, 13) = Me.Reg13.Text
Cells(rowselect, 14) = Me.Reg14.Text
MsgBox "Container updated!"
Sheets("Main Screen").Select
Unload Me
Sheet1.Protect Password:="manlog"
Sheet7.Protect Password:="manlog"
End Sub
Last edited by a moderator: