View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Terry Detrie[_2_] Terry Detrie[_2_] is offline
external usenet poster
 
Posts: 5
Default 1004 Error with Range/Array


I had run this code 5 times on seperate occasions with different data
sets and generated the same error.

As for resetting the range for Source, it is dynamically defined using
OFFSET function. It automatically updates (correctly, I've checked)
after copying data.

I'll try the Copy/Paste method, but it still bugs me that this equally
valid approach doesn't seem to work.

Terry

On Sun, 27 Jul 2008 18:24:19 -0700, OssieMac
wrote:

I tested the code and it appears to work fine. I am assuming that you run
this multiple times with new data and each time the data is to be placed
below the previous data. Is this assumption correct?

If above is correct, are you resetting the range for "Source" correctly
after copying the data? I would use one of the following lines of code to do
this:-

ActiveWorkbook.Names.Add Name:="Source", RefersToR1C1:=RR

or because you only need one cell to be named "Source" because you resize
the range for the data you could use the following:-

ActiveWorkbook.Names.Add Name:="Source", _
RefersToR1C1:=RR.Cells(RR.Rows.Count, 1)


The only other thing I can think of that might cause problems but I can't
test is memory problems assigning the array to a variant. Perhaps you could
try copy and paste instead of assigning to an array first.