Share via

Will a Normal Paste Macro Paste Into a Protected or Hidden Area or Sheet?

Anonymous
2011-12-03T04:00:02+00:00

Just would like to know before I get into a macro for a button that will execute a number of functions, including Copy/Paste.  I guess I am asking 2 questions really:

  1.  Paste into a cell protected area?
  2.  Hidden sheet or cell range?

Thanks

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2011-12-03T04:25:00+00:00

You cannot paste into a locked area of a protected sheet.

Generally your macro will copy, unprotect the sheet, do the paste then reprotect the sheet.

Activesheet.unprotect password:="pword"

      do the pasting

Activesheet.protect password:="pword"

As far as hidden sheets go...............you can add data to a hidden sheet just by sending it there

Assume in both cases below that Sheet2 is hidden.

Sub copy_to_hidden_sheet()

    Dim rng1, rng2 As Range

    Set rng1 = Sheets("Sheet1").Range("A1:F23")

    Set rng2 = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp) _

               .Offset(1, 0)

    rng1.Copy Destination:=rng2

End Sub

Or by this method

Sub value_only()

Dim rng1, rng2 As Range

    Set rng1 = Sheets("Sheet1").Range("A1").EntireRow

    Set rng2 = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp) _

               .Offset(1, 0).EntireRow

    rng2.Value = rng1.Value

End Sub

Gord

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2011-12-03T05:16:53+00:00

    Thankyou...

    Was this answer helpful?

    0 comments No comments