ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Cut and Paste Macro (https://www.excelbanter.com/excel-discussion-misc-queries/140801-cut-paste-macro.html)

M.A.Tyler

Cut and Paste Macro
 
I have a sheet with the following macro, actually this is just part of it. If
I'm correct it cuts rows from sheet 9 Rows("2:11") and pastes them to sheet
1("A7"). it works fine, however I would like to modify it so that it cuts the
rows, but skips columns (cells) BX, BY, BZ in each row. These columns (cells)
have formulas that become overwritten when the current macro runs. is there a
way to make this work?

Sheets("Sheet9").Select
Rows("2:11").Select
Selection.Copy
Sheets("Sheet1").Select
Range("A7").Select
ActiveSheet.Paste

Thanks,
M.A.Tyler

JE McGimpsey

Cut and Paste Macro
 
One way:

With Sheets("Sheet9")
.Range("A2:BW11").Copy Destination:=Sheets("Sheet1").Range("A7")
.Range("CA2:IV11").Copy Destination:=Sheets("Sheet1").Range("CA7")
End With

Note that no selection is needed. Working with range objects directly is
usually faster and produces more manageable code.

In article ,
M.A.Tyler <Great Lakes State wrote:

I have a sheet with the following macro, actually this is just part of it. If
I'm correct it cuts rows from sheet 9 Rows("2:11") and pastes them to sheet
1("A7"). it works fine, however I would like to modify it so that it cuts the
rows, but skips columns (cells) BX, BY, BZ in each row. These columns (cells)
have formulas that become overwritten when the current macro runs. is there a
way to make this work?

Sheets("Sheet9").Select
Rows("2:11").Select
Selection.Copy
Sheets("Sheet1").Select
Range("A7").Select
ActiveSheet.Paste

Thanks,
M.A.Tyler


Pete_UK

Cut and Paste Macro
 
Instead of your second line:

Rows("2:11").Select

make this:

Range("A2:BW11").Select

If you have any data beyond column BZ that you also want to cut/paste,
then just repeat the lines you have but with the range CA2:IV11, and
instead of Range("A7").Select you would have Range("CA7").Select.

Hope this helps.

Pete

On Apr 28, 12:58 am, M.A.Tyler <Great Lakes State wrote:
I have a sheet with the following macro, actually this is just part of it. If
I'm correct it cuts rows from sheet 9 Rows("2:11") and pastes them to sheet
1("A7"). it works fine, however I would like to modify it so that it cuts the
rows, but skips columns (cells) BX, BY, BZ in each row. These columns (cells)
have formulas that become overwritten when the current macro runs. is there a
way to make this work?

Sheets("Sheet9").Select
Rows("2:11").Select
Selection.Copy
Sheets("Sheet1").Select
Range("A7").Select
ActiveSheet.Paste

Thanks,
M.A.Tyler




M.A.Tyler

Cut and Paste Macro
 
Both of these worked great!

"Pete_UK" wrote:

Instead of your second line:

Rows("2:11").Select

make this:

Range("A2:BW11").Select

If you have any data beyond column BZ that you also want to cut/paste,
then just repeat the lines you have but with the range CA2:IV11, and
instead of Range("A7").Select you would have Range("CA7").Select.

Hope this helps.

Pete

On Apr 28, 12:58 am, M.A.Tyler <Great Lakes State wrote:
I have a sheet with the following macro, actually this is just part of it. If
I'm correct it cuts rows from sheet 9 Rows("2:11") and pastes them to sheet
1("A7"). it works fine, however I would like to modify it so that it cuts the
rows, but skips columns (cells) BX, BY, BZ in each row. These columns (cells)
have formulas that become overwritten when the current macro runs. is there a
way to make this work?

Sheets("Sheet9").Select
Rows("2:11").Select
Selection.Copy
Sheets("Sheet1").Select
Range("A7").Select
ActiveSheet.Paste

Thanks,
M.A.Tyler






All times are GMT +1. The time now is 02:37 AM.

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