I have got below macro to paste values only and I have assisgned Ctl+V as a shortcut.
Sub PasteasValue()
Selection.PasteSpecial Paste:=xlPasteValues
End Sub
With this method, end user have issue of pasting data on hidden rows, so I amended the code to select only visible cells. Rows are hidden when filters are on.
Sub PasteasValue()
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.PasteSpecial Paste:=xlPasteValues
End Sub
However, my spreadsheet is protected and now it will give me an error at first code.
I tried below code to unprotect and protect the sheet, but this will not work as I understand the copied data on the clipboard is deleted when you unprotect the sheet and it will give me an error at paste value level.
Sub PasteasValue()
Activesheet.Unprotect "1234"
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.PasteSpecial Paste:=xlPasteValues
Activesheet.Protect "1234"
End Sub
Below is what I am trying to achieve
- Copy paste as value
- Paste only in visible cells
- Keep the sheet protected
- Code should work for all worksheets in this workbook (all worksheets have same password)
Is there any simple method to achieve above?
Please help.
Thanks,
Rik