Macro Error When Trying to Copy

MikeG

Well-known Member
Joined
Jul 4, 2004
Messages
845
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I have created the macro shown below. The idea is when the user enters a new number in Cell D5, the macro goes to another worksheet and simply copies the value in K11.


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address(False, False) = "D5" Then
Sheets("Quotes Database").Select
Range("K11").Select
Selection.Copy
End If

End Sub


The problem is when it runs, I get a...

Runtime Error 1004

Select method of Range class failed

...and the macro stops on the "Range("K11").Select" line.

I would appreciate any help.

Thanks,

MikeG
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Event code is placed in the Sheet's module.

Unqualified ranges in a Sheet module refer to that sheet, regardless of which sheet is active/selected.

Try changing all this

Sheets("Quotes Database").Select
Range("K11").Select
Selection.Copy

to

Sheets("Quotes Database").Range("K11").Copy
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,317
Members
452,905
Latest member
deadwings

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