View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Error Copying Range/Cell with long Text String

rngPaste.Value = left(rngCopy.Value,256)

"MikeZz" wrote:

Hi
I have a macro that copies a row of data from one workbook to another if it
meets certain criteria.
rngCopy is the range being copied,
rngPaste is the range I where I copy it to.
Each range contains multiple cells.

I get error 1004 when part of the copy range has a cell with a lot of
text... it probably trigger's that error in Excel when you try to copy a cell
which is to many characters. I did notice that it copied all the preceding
cells in the copy range to the paste range and errored out on the first one
that was "to big".

Since I'm using the rngPaste.Value = rngCopy.Value, I don't want to check
the length of each cell before copying.

Is there a way to truncate any cells easily?

Thanks,
MikeZz

Here's the reader's digest of my code causing the error:

Set rngCopy = ManagerFileSht.Range("A" & testRow + r & ":N" & testRow + r)
pasteRow = firstPasteRowClosed + countCopyClosed
Set rngPaste = pasteClosed.Range("C" & pasteRow & ":P" & pasteRow)
rngPaste.Value = rngCopy.Value