If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Copy a range from one sheet to another

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-12-05, 12:30
mmbosman mmbosman is offline
Registered User
 
Join Date: Apr 2004
Posts: 171
Copy a range from one sheet to another

Why doesn't the following work

Public Sub test()
Dim rng As Range, rng2 As Range
Set rng = Range("d_21")
Set rng2 = Range("div_21")
rng.Copy
rng2.PasteSpecial xlPasteAll
End Sub

I get a runtime error 1004. Application defined or object defined error. What gives. All I need to do is paste the range d_21 to div_21. Any ideas appreciated.
Reply With Quote
  #2 (permalink)  
Old 01-12-05, 15:10
DavidCoutts DavidCoutts is offline
Registered User
 
Join Date: Jan 2004
Location: Aberdeen, Scotland
Posts: 1,067
try fully qualifying your references
i.e.
worksheets("Sheet1").Range("div_21").Formula = Worksheets("Sheet2").Range("d_21").Fomula

another possibility is that excel is not picking up your named ranges try using the actual cell references

all the best
Dave
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On