Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 14
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,344
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 427
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 14
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default 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
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
Missing text from copy/paste Malora Excel Discussion (Misc queries) 1 September 14th 06 06:13 PM
Transfer text w/o Copy&Paste Excel Curious Excel Discussion (Misc queries) 0 June 13th 06 07:28 PM
How can I copy and paste the text of a formula? Jeff Excel Worksheet Functions 1 August 30th 05 03:45 PM
Copy and paste text and dates Kitty Excel Discussion (Misc queries) 5 March 15th 05 11:03 PM
Copy and Paste to a Text Box Margie Excel Discussion (Misc queries) 1 January 7th 05 04:31 PM


All times are GMT +1. The time now is 05:25 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"