Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
VBA text for copy + paste
I'm trying to copy a cell from directly above of a particular cell and insert
it into the given cell, as part of a macro. What commands would that consist of in VBA? Thank you very much! |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
VBA text for copy + paste
Assuming you are asking because the cell you want to fill in is variable,
see if this does what you want... CellAddress = "S9" ...... ...... Range(CellAddress).Value = Range(CellAddress).Offset(-1, 0).Value Rick "Makaron" wrote in message ... I'm trying to copy a cell from directly above of a particular cell and insert it into the given cell, as part of a macro. What commands would that consist of in VBA? Thank you very much! |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
VBA text for copy + paste
Hi,
Move to the cell where you want to start from (the one below the one you want to copy). Turn on the macro recorder and record the code. (Tools, Macro, Record New Macro). -- Cheers, Shane Devenshire "Makaron" wrote: I'm trying to copy a cell from directly above of a particular cell and insert it into the given cell, as part of a macro. What commands would that consist of in VBA? Thank you very much! |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
VBA text for copy + paste
One way: This code copies the cell directly above the current cell,
returns to the current cell and pastes: activecell.offset(-1,0).select selection.copy activecell.offset(1,0).select activesheet.paste Dave O Eschew obfuscation |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
VBA text for copy + paste
Yep - that's what I was looking for. Thank you!
"Dave O" wrote: One way: This code copies the cell directly above the current cell, returns to the current cell and pastes: activecell.offset(-1,0).select selection.copy activecell.offset(1,0).select activesheet.paste Dave O Eschew obfuscation |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
VBA text for copy + paste
Just as a follow up, you don't need to actually select the cell to copy it.
This code will do the identical thing that Dave O's code does... ActiveCell.Offset(-1, 0).Copy ActiveCell or, if you like the self documenting nature of named arguments, like this... ActiveCell.Offset(-1, 0).Copy Destination:=ActiveCell Rick "Makaron" wrote in message ... Yep - that's what I was looking for. Thank you! "Dave O" wrote: One way: This code copies the cell directly above the current cell, returns to the current cell and pastes: activecell.offset(-1,0).select selection.copy activecell.offset(1,0).select activesheet.paste Dave O Eschew obfuscation |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Missing text from copy/paste | Excel Discussion (Misc queries) | |||
Transfer text w/o Copy&Paste | Excel Discussion (Misc queries) | |||
How can I copy and paste the text of a formula? | Excel Worksheet Functions | |||
Copy and paste text and dates | Excel Discussion (Misc queries) | |||
Copy and Paste to a Text Box | Excel Discussion (Misc queries) |