PDA

View Full Version : Copy from a cell and insert in another on a new line with a date



Phelony
06-04-2009, 02:04 AM
Hi guys

Really stuck on how to use the Chr(10) gizmo.

What I've got is one sheet that stores data and another that allows it to be edited. So the edit screen pulls information from the database, it's then edited and goes back into the database when a macro is initiated.

However, to create an audit trail I need to keep the original input. So what I'd need to do is effectively

Range("A1").copy
Range("B1") & Chr(10) & Date() & Chr(10).paste


I know this is wrong but I really can't find an example of any code anywhere through the power of Google that seems to be correct.

I'm sorta stuck (sorta = very) in how to get Chr(10) to work properly. Every example I've looked up depends on knowing what the text to be input is in advance, which I can't.

Could anyone point me in the right direction and let me know how to use the Carriage return command properly? (The other glaring errors I can fix, but this one I need a hand with!)

Thanks

Phel x

mdmackillop
06-04-2009, 04:54 AM
Avoid the copy

Range("B1") = Range("A1").Value & Chr(10) & Date & Chr(10)

Phelony
06-04-2009, 05:31 AM
That's great thanks. Pleased I wasn't an entire universe away from it!

Do you know of a way to do this but still keep the original content of cell B1 intact though? This code copies over it and I would like to keep the original cell content.


So if B1 contains "First"
And A1 contains "Second"

The net result is

"Second
01/01/2009
First"

Phel x

mdmackillop
06-04-2009, 05:32 AM
Range("B1") = Range("B1") & " - " & Range("A1").Value & Chr(10) & Date & Chr(10)

Phelony
06-04-2009, 05:34 AM
Range("B1") = Range("B1") & " - " & Range("A1").Value & Chr(10) & Date & Chr(10)


Genius

Thanks :clap:

Phel x