Issue with locking a sheet with macro and table

skf786

Board Regular
Joined
Sep 26, 2010
Messages
156
Hello,

im running a macro to paste additional data to a table. So data grows by one row each time the macro is run. in trying to lock the sheet but have kept the range of the table 'unlocked' however the macro does not perform properly and when it is run the new data is pasted outside the table.

here is the macro being used.

any suggestions to fic this would be highly appreciate.

VBA Code:
Sub Create_Segment()
'
' Create_Segment Macro
'
' Keyboard Shortcut: Ctrl+Shift+S
'
    Range("D29:K29").Select
    Selection.Copy
    Range("Table13[[#Headers],[Segment Code]]").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E10:E13").Select
    Application.CutCopyMode = False
    Selection.ClearContents
    Range("E10").Select
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
The ranges that are locked / unlocked will be set as specific ranges, not to the current size of the table.

You will need to unlock the sheet for the code to run correctly, you can do this at the start of the code then re-protect at the end.

 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,192
Members
449,072
Latest member
DW Draft

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