ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Macro for Insert/ Copied Cells (https://www.excelbanter.com/excel-worksheet-functions/235891-macro-insert-copied-cells.html)

Tami

Macro for Insert/ Copied Cells
 
I need a macro that allows a user to Copy/paste a set of rows (named "Style")
whereever the cursor is.

"Style" and is defined as Sheet1!$200:$203

So if my cursor is on row 10, it will Copy all of all rows 200-203 and
insert them at row 10.

thanks in advance for your help
tami

Jacob Skaria

Macro for Insert/ Copied Cells
 
Tami, try the below macro..

Sub Mac()
Range("style").Copy Selection
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Tami" wrote:

I need a macro that allows a user to Copy/paste a set of rows (named "Style")
whereever the cursor is.

"Style" and is defined as Sheet1!$200:$203

So if my cursor is on row 10, it will Copy all of all rows 200-203 and
insert them at row 10.

thanks in advance for your help
tami


Shane Devenshire[_2_]

Macro for Insert/ Copied Cells
 
Hi,

If you want to Insert them then you need slightly different code that
suggested in the previous post, which will overwrite the contents of the
destination rows.

Range("Styles").Copy
Cells(ActiveCell.Row, 1).Insert

If on the otherhand, you want to overwrite the current selection try

Range("Styles").Copy Cells(ActiveCell.Row, 1)

This handles the possiblity that the cursor is not in column A which will
generate an error if you try to copy a whole row.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"Tami" wrote:

I need a macro that allows a user to Copy/paste a set of rows (named "Style")
whereever the cursor is.

"Style" and is defined as Sheet1!$200:$203

So if my cursor is on row 10, it will Copy all of all rows 200-203 and
insert them at row 10.

thanks in advance for your help
tami



All times are GMT +1. The time now is 10:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com