Insert Row Include Formulas - Protected Sheet

Kirrash

New Member
Joined
Jan 10, 2024
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Hello! I have created a workbook for supervisors to track employee case files. Formulas I use are often overwritten by unaware users. Frustrating as I always have to go back in and fix. My thinking then, is to lock the spreadsheet down and have a macro button to insert a new row (unlocking the sheet first so formulas will copy as well).

I have tried two separate ways, and both times column "I" just does not have the formula copied. Columns E, G, L, N, Q work as intended.

A look at the spreadsheet (cursor currently on I6 where formula has not been copied.

1704923135314.png


"Button 41" at top left is what initiates the macro.

I have tried two different codes to achieve this - and both do not copy column I. Any ideas?

Thank you!

p.s. this is my first posting so if I need to seriously rework this tell me and I will jump on it.

File _Sample Macro Fill2.xlsm code:
SQL:
Sub Button41_Click()
 
Dim PswS As String
pswStr = "123"

On Error Resume Next

Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:=pswStr

ActiveSheet.ListObjects("Table1").ListRows.Add

ActiveSheet.Protect Password:=pswStr
Application.ScreenUpdating = True
End Sub
============================
_Sample Macro Fill3.xlsm:
SQL:
Sub Button41_Click()
Dim pswStr As String
pswStr = "123"
On Error Resume Next
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:=pswStr
ActiveSheet.Range("D1").Select
'D8 is table header
Range("Table1[[#Headers],[e]]").Select
Range("Table1[[#Headers],[g]]").Select
Range("Table1[[#Headers],[I]]").Select
Range("Table1[[#Headers],[L]]").Select
Range("Table1[[#Headers],[N]]").Select
Range("Table1[[#Headers],[Q]]").Select


Selection.End(xlDown).Select
Selection.ListObject.ListRows.Add AlwaysInsert:=False
ActiveSheet.Protect Password:=pswStr
Application.ScreenUpdating = True
End Sub
 

Attachments

  • 1704923041248.png
    1704923041248.png
    12.1 KB · Views: 36

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
This will be more than likely due to you having created the formula or modifying it after you created the table. If formulas are all the same in a column, change back to a range and then re-format as a table, new lines added at the bottom of the table will then auto copy the formula down.
 
Upvote 1
Solution
This will be more than likely due to you having created the formula or modifying it after you created the table. If formulas are all the same in a column, change back to a range and then re-format as a table, new lines added at the bottom of the table will then auto copy the formula down.
Good morning! That was an excellent idea. Converted to range, reformatted as table - same result. Macro inserts row and formulas on all columns but I. I'll keep trying. Appreciate the input.
 
Upvote 0
Good morning! That was an excellent idea. Converted to range, reformatted as table - same result. Macro inserts row and formulas on all columns but I. I'll keep trying. Appreciate the input.
Actually, it WORKED! I tried using the 2nd excel _Sampe Macro Fill 3. Amazing! My life just became SO much simpler. Thank you for your guidance.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top