Help with Copy Formula

Roadking

Board Regular
Joined
Feb 15, 2014
Messages
78
Good morning

The below list formula copies contents from specific cells from one worksheet to another. The problem is cell "A21" has a formula (=year(Now()) so when the cells are copied it copies the formula rather than the cell content.

Any help appreciated and thank you.

Sub EnterInfo()
'
' EnterInfo Macro
'
' Keyboard Shortcut: Ctrl+z
'
ActiveSheet.Unprotect

Range("A21").Select

Dim FromRng As Range
Dim ToRng As Range

With Worksheets("Data Entry Sheet")
Set FromRng = .Range("A21:L21")
End With

With Worksheets("Activity")
Set ToRng = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

FromRng.Copy _
Destination:=ToRng

With Worksheets("Data Entry Sheet")
Set FromRng = .Range("B21:L21")
FromRng.ClearContents
Range("B21").Select
End With

Range("A21").Select

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True
ActiveSheet.Unprotect
Range("B21").Select
Selection.Locked = False
Selection.FormulaHidden = False
Range("B21").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True

End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Try changing:
Code:
FromRng.Copy _
       Destination:=ToRng

To this:
Code:
FromRng.Copy
ToRng.PasteSpecial (xlPasteValues)
 
Upvote 0

Forum statistics

Threads
1,215,061
Messages
6,122,922
Members
449,094
Latest member
teemeren

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