Solved

Trying to copy a value from 1 worksheet to another

Posted on 2013-11-15
2
387 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
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now