![]() |
Array to copy columns
Hi,
I would like to copy from Sheet1 Columns B ,A, C in that order to Sheet 2 Columns A , B, C can this be done by array i.e myarray(B,A,C) Thanks in advance -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/201005/1 |
Array to copy columns
I found this code but the order of columns remains A,B,C
myarray = "B:B,A:A,C:C" Worksheets("Sheet1").Range(myarray).Copy Worksheets("Sheet2").Range("A1") FIRSTROUNDKO wrote: Hi, I would like to copy from Sheet1 Columns B ,A, C in that order to Sheet 2 Columns A , B, C can this be done by array i.e myarray(B,A,C) Thanks in advance -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/201005/1 |
Array to copy columns
here is the answer
Sub assignArray() Dim Arr(3) Dim X As Long Arr(1) = "B:B" Arr(2) = "A:A" Arr(3) = "C:C" For X = 1 To 3 ' Columns("K:K").Select Worksheets("Sheet1").Columns(Arr(X)).Copy Worksheets ("Sheet2").Cells(1, X) Next X End Sub FIRSTROUNDKO wrote: I found this code but the order of columns remains A,B,C myarray = "B:B,A:A,C:C" Worksheets("Sheet1").Range(myarray).Copy Worksheets("Sheet2").Range("A1") Hi, [quoted text clipped - 9 lines] Thanks in advance -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/201005/1 |
Array to copy columns
Another way
Sub CopycolumnsCustom() With Sheets("Sheet14") Sheets("sheet9").Columns("A:C").Copy .Range("a1") Application.CutCopyMode = False .Columns("B").Cut .Columns("A").Insert , Shift:=xlToRight End With End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "FIRSTROUNDKO via OfficeKB.com" <u15639@uwe wrote in message news:a7a6c6f60e4a6@uwe... here is the answer Sub assignArray() Dim Arr(3) Dim X As Long Arr(1) = "B:B" Arr(2) = "A:A" Arr(3) = "C:C" For X = 1 To 3 ' Columns("K:K").Select Worksheets("Sheet1").Columns(Arr(X)).Copy Worksheets ("Sheet2").Cells(1, X) Next X End Sub FIRSTROUNDKO wrote: I found this code but the order of columns remains A,B,C myarray = "B:B,A:A,C:C" Worksheets("Sheet1").Range(myarray).Copy Worksheets("Sheet2").Range("A1") Hi, [quoted text clipped - 9 lines] Thanks in advance -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/201005/1 |
All times are GMT +1. The time now is 06:18 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com