Copy range lead to lost data

G

Guest

I am using excel 2000

i use the following code:

oBook.Worksheets(name).Range("$E" & temp2).Copy
(newBook.Worksheets(name).Range("$E" & temp1))

the range is with thousand of character

when i copy the range to another sheet, part of the data are missing..

although i can use the range1.value = range2.value to preserve the data
but all the formating in the cell will be lost.
 
W

William Benson

Go ahead and use the value property as you described, then include these
steps:

oBook.Worksheets(name).Range("$E" & temp2).Copy
newBook.Worksheets(name).Range("$E" & temp1).Select
Selection.PasteSpecial Paste:=xlPasteFormats

There may even be a way around selecting the area to paste to, I didn't
think too much about it.
 
G

Guest

this does not work if the data inside the cell have different formats
I CAN GET format character by character, but the program may run slower.
anyway, thank you for your help
 
W

William Benson

OK, did you perhaps copying the format first?

Laguna said:
this does not work if the data inside the cell have different formats
I CAN GET format character by character, but the program may run slower.
anyway, thank you for your help
 
G

Guest

Thank you for your help.
Finally I find the way for the solution
Instead of just simple paste
i use the pasteSpecial(xlPasteAll)
this will make all format and value preserved without lost
 
W

William Benson

I am surprised this did not result in the 256 character limitation ... good
job!
 

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