Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default Error Copying Range/Cell with long Text String

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




  #2   Report Post  
Posted to microsoft.public.excel.programming
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Messages: 'Text String is Too Long...'; 'Can't Record Macro' ryguy7272 Excel Programming 0 July 9th 08 07:46 PM
Error: The text string you entered is too long. GTVT06 Excel Worksheet Functions 2 June 16th 06 10:44 PM
Error: The text string you entered is too long. GTVT06 Excel Programming 1 June 16th 06 08:32 PM
Error: The text string you entered is too long. GTVT06 Excel Discussion (Misc queries) 0 June 16th 06 06:41 PM
text in cell too long? run-time error screeb Excel Programming 3 March 5th 04 10:02 AM


All times are GMT +1. The time now is 10:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"