ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Macro Question (https://www.excelbanter.com/excel-worksheet-functions/143018-macro-question.html)

Carl

Macro Question
 
Is there a way to repeat this macro for columns C thru Z on Sheet2 ?



Sheets("Sheet2").Select

Range("C3:C344").Select

Selection.Copy

Sheets("Sheet3").Select

Range("A2").Select

Selection.End(xlDown).Select

ActiveCell.Offset(1, 0).Range("A1").Select

ActiveSheet.Paste

Thank you in advance.



bj

Macro Question
 
simplest way if you want to do what I think you want to do is change
Range("C3:C344").Select
to
Range("C3:Z344").Select

if you need each column to go to column A individulally to do something else.

for c = 3 to 26
Sheets("Sheet2").Select

Range(cells(3,C),Cells(344,C).Select

Selection.Copy

Sheets("Sheet3").Select

Range("A2").Select

Selection.End(xlDown).Select

ActiveCell.Offset(1, 0).Range("A1").Select

ActiveSheet.Paste

rest of your action
next C


"carl" wrote:

Is there a way to repeat this macro for columns C thru Z on Sheet2 ?



Sheets("Sheet2").Select

Range("C3:C344").Select

Selection.Copy

Sheets("Sheet3").Select

Range("A2").Select

Selection.End(xlDown).Select

ActiveCell.Offset(1, 0).Range("A1").Select

ActiveSheet.Paste

Thank you in advance.



Don Guillett

Macro Question
 
to copy c3:z344 to the last available row from the bottom up on sheet 2. NO
selections

dlr=sheets("sheet3").cells(rows.count,"a").end(xlu p).row+1
sheets("sheet2").range(c3:z344").copy sheets("sheet3").cells(dlr,1)

--
Don Guillett
SalesAid Software

"carl" wrote in message
...
Is there a way to repeat this macro for columns C thru Z on Sheet2 ?



Sheets("Sheet2").Select

Range("C3:C344").Select

Selection.Copy

Sheets("Sheet3").Select

Range("A2").Select

Selection.End(xlDown).Select

ActiveCell.Offset(1, 0).Range("A1").Select

ActiveSheet.Paste

Thank you in advance.




Gord Dibben

Macro Question
 
You could tidy this up to get rid of the "selects".

Assuming you want columns C through Z copied and pasted into column A in Sheet3

Sub foo()
For C = 3 To 26
With Sheets("Sheet2")
Range(Cells(3, C), Cells(344, C)).Copy Destination:=Sheets("Sheet3") _
.Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0)
End With
Next C
End Sub


Gord Dibben MS Excel MVP

On Wed, 16 May 2007 12:41:01 -0700, bj wrote:

simplest way if you want to do what I think you want to do is change
Range("C3:C344").Select
to
Range("C3:Z344").Select

if you need each column to go to column A individulally to do something else.

for c = 3 to 26
Sheets("Sheet2").Select

Range(cells(3,C),Cells(344,C).Select

Selection.Copy

Sheets("Sheet3").Select

Range("A2").Select

Selection.End(xlDown).Select

ActiveCell.Offset(1, 0).Range("A1").Select

ActiveSheet.Paste

rest of your action
next C


"carl" wrote:

Is there a way to repeat this macro for columns C thru Z on Sheet2 ?



Sheets("Sheet2").Select

Range("C3:C344").Select

Selection.Copy

Sheets("Sheet3").Select

Range("A2").Select

Selection.End(xlDown).Select

ActiveCell.Offset(1, 0).Range("A1").Select

ActiveSheet.Paste

Thank you in advance.





All times are GMT +1. The time now is 12:41 PM.

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