Problem copying named range

I

IanC

I have a named range on a Lookup sheet which I am trying to copy to a
destination on the main sheet (Mobiles).

The range named PlugIn occupied V4:Z4 on the Lookup sheet and has a border
round the entire area (none internal). This is a region title and only has
text in V4.

Using the following bits of code to copy the range to V6 on the Mobiles
sheet, I end up with the text in V6 as expected, but the border only
surrounds V6, not V6:Z6.

With Worksheets("Lookup")
Set PlugIn = .Range("PlugIn")
End With

PlugIn.Copy (Worksheets("Mobiles").Range("V6"))

I've tried merging V4:Z4 in Lookup, but exactly the same thing happens.
I've tried also merging the cells before copying, but then the border is
completely missing

I know I can copy the range then apply the border, but this shouldn't be
necessary.

Any ideas?
 
D

Don Guillett

Sub copyplugin()' should work from anywhere in the workbook.
Range("plugin").Copy Sheets("mobiles").Range("v6")
End Sub
 
I

IanC

Hi Don

Thanks for the response

Don Guillett said:
Sub copyplugin()' should work from anywhere in the workbook.
Range("plugin").Copy Sheets("mobiles").Range("v6")
End Sub

This gives me Run-time error '1004': - Method 'Range' of object '_Worksheet'
failed.

I had previously looked carefully at the formatting of the destination area,
but couldn't see anything wrong. I didn't think to check the named range.
Although V4:Z4 was merged, and selecting it showed PlugIn in the name box,
the actual named range was only V4. Once I corrected this, my original code
works.

I still can't get your code to work, though. It would be good if I could
figure out where it's failing as I currently have many Set lines in my code
(this particular workbook has 25, but I have several similar workbooks and
each has more named ranges than the one I'm currently working on (the most
involved workbook has nearly 100 Set lines). With your code I could do away
with the Set lines and pass named & destination ranges to your subroutine
instead.

Any thoughts?
 
D

Don Guillett

If desired, send your file to my address below. I will only look if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top