Run Time Error Issue

JessKong1

New Member
Joined
Oct 2, 2016
Messages
1
Hi!

I used the code below in a hidden worksheet so that if text is entered into a template and then deleted, the formulas will reappear. Sometimes, but not always, I receive the following error.

Run-time error '-2147417848 (80010108)' Method 'Formula' of object 'Range failed

This is the code that I am currently using.

<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit;">Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Count > 1 Then Exit Sub
If Intersect(Target, Range("D5:I26")) Is Nothing Then Exit Sub
If Target = "" Then
Target.Formula = Sheets("Saturday Hidden").Cells(Target.Row, Target.Column).Formula
End If

End Sub

The error is occurring at this point [FONT=&quot]Target.Formula = Sheets("Saturday Hidden").Cells(Target.Row, Target.Column).Formula[/FONT]

Can someone please advise on what needs to be modified in order for the macro to work properly?</code>
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
You could have an infinite loop triggering, try:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)


Application.EnableEvents = False


If Target.Count > 1 Then Exit Sub
If Intersect(Target, Range("D5:I26")) Is Nothing Then Exit Sub
If Target = "" Then
Target.Formula = Sheets("Saturday Hidden").Cells(Target.Row, Target.Column).Formula
End If


Application.EnableEvents = True


End Sub
 
Upvote 0
You should also verify is the cell in sheets("Saturday Hidden") has a formula thanks to the function HasFormula, before you "copy/paste" this formula.
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,877
Members
449,056
Latest member
ruhulaminappu

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