I have a worksheet for about 50 users that I want to protect. They are using it for data entry and I am trying to several limit the amount of free typing.
THat also have to insert rows occassionally. With some help from the board, I have a macro that automatically inserts a new row and auto-numbers it. HOwever, when I protect the worksheet--even if I allow people the right to insert rows--my Macro no longer works.
I basically want to protect my sheet so the format, data validation, etc are preserved.
Sub InsertRow()
Dim a As Integer
Dim X As String
X = ActiveCell.Value
If Len(X) = 7 Then GoTo NoCountNumber:
On Error GoTo NoCountNumber:
a = CInt(Right(X, 2))
If a > 0 And a < 9 Then
a = a + 1
With ActiveCell
.EntireRow.Copy
.Offset(1, 0).EntireRow.Insert Shift:=xlDown
.Offset(1, 0).Value = Left(X, Len(X) - 2) & CStr("0" & a)
End With
Application.CutCopyMode = False
Else
a = a + 1
With ActiveCell
.EntireRow.Copy
.Offset(1, 0).EntireRow.Insert Shift:=xlDown
.Offset(1, 0).Value = Left(X, Len(X) - 2) & CStr(a)
End With
End If
GoTo Finish:
NoCountNumber:
With ActiveCell
.EntireRow.Copy
.Offset(1, 0).EntireRow.Insert Shift:=xlDown
.Offset(1, 0).Value = X & "_01"
End With
Application.CutCopyMode = False
Finish:
End Sub
THat also have to insert rows occassionally. With some help from the board, I have a macro that automatically inserts a new row and auto-numbers it. HOwever, when I protect the worksheet--even if I allow people the right to insert rows--my Macro no longer works.
I basically want to protect my sheet so the format, data validation, etc are preserved.
Sub InsertRow()
Dim a As Integer
Dim X As String
X = ActiveCell.Value
If Len(X) = 7 Then GoTo NoCountNumber:
On Error GoTo NoCountNumber:
a = CInt(Right(X, 2))
If a > 0 And a < 9 Then
a = a + 1
With ActiveCell
.EntireRow.Copy
.Offset(1, 0).EntireRow.Insert Shift:=xlDown
.Offset(1, 0).Value = Left(X, Len(X) - 2) & CStr("0" & a)
End With
Application.CutCopyMode = False
Else
a = a + 1
With ActiveCell
.EntireRow.Copy
.Offset(1, 0).EntireRow.Insert Shift:=xlDown
.Offset(1, 0).Value = Left(X, Len(X) - 2) & CStr(a)
End With
End If
GoTo Finish:
NoCountNumber:
With ActiveCell
.EntireRow.Copy
.Offset(1, 0).EntireRow.Insert Shift:=xlDown
.Offset(1, 0).Value = X & "_01"
End With
Application.CutCopyMode = False
Finish:
End Sub