Solved

Trying to copy a value from 1 worksheet to another

Posted on 2013-11-15
2
427 Views
Last Modified: 2013-11-15
I have the following sub routine that is trying to copy a data cell from one worksheet to another…

Sub Copy_Data()
Dim DataString As String

  Application.ScreenUpdating = False
  DataString = Worksheets("Data").Range("E2:E2").Value

  Worksheets("Data").Range("E2:E2").Select
 Selection.Copy
  Worksheets("DRA Summary").Range("F5:F5").Select
  Selection.Paste
 
  Application.ScreenUpdating = True

End Sub


When the statement below is executed…
Worksheets("Data").Range("E2:E2").Select

This error occurs…
Run-time error '1004':
Select method of Range class failed.

I am trying to copy the data in cell E2 from the worksheet named “Data” to
Cell F5 in the worksheet named “DRA Summary”

Can anyone help with this or suggest a better way of accomplishing this data copy?

Thanks.
0
Comment
Question by:tesla764
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

by:
mvidas earned 500 total points
ID: 39651959
Hi Tesla,

You can avoid the select issue by simply applying the .Copy to the actual range object rather than the selection range object:
  Worksheets("Data").Range("E2").Copy
  Worksheets("DRA Summary").Range("F5").Paste

Open in new window


Another option to do that is to use the Destination argument of the .copy method:
Worksheets("Data").Range("E2").Copy Destination:=Worksheets("DRA Summary").Range("F5")

Open in new window


You could also just move the inner value from one cell to the other:
Worksheets("DRA Summary").Range("F5").Value = Worksheets("Data").Range("E2").Value

Open in new window

Many ways to do similar things :)
Matt
0
 

Author Closing Comment

by:tesla764
ID: 39651973
Thanks Matt. That works great. I am taking this assignment one elementry step at a time. Very good so far. On to the next step.
Thanks for your help.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question