L
L. Howard
The code works fine copying to the resized Range M2 in the target workbook.
wksTarget.Range("M2").Resize(columnsize:=myRng.Cells.Count) = myArr
I want his array from wksSource
Set myRng = Range("A2,A4,R20,C10,N2,O4,F8,H12,G14")
To workbook "Copy of long.xlsm"
wksTarget.Columns.[8, 6, 4, 5, 3, 7, 2 ,10, 3].End(xlUp)(2) = myArr
(translated to workable code of course)
Thanks.
Howard
Sub AbookToLong()
Dim myRng As Range, MyRng1 As Range
Dim rngC As Range
Dim i As Long
Dim myArr() As Variant
Dim wksSource As Worksheet, wksTarget As Worksheet
Dim wkbSource As Workbook, wkbTarget As Workbook
Dim rngSource As Range, rngTarget As Range
Set myRng = Range("A2,A4,R20,C10,N2,O4,F8,H12,G14")
Set wkbSource = Workbooks("Array cells to another workbook.xlsm")
Set wkbTarget = Workbooks("Copy of long.xlsm")
Set wksSource = wkbSource.Sheets("Sheet1")
Set wksTarget = wkbTarget.Sheets("Sheet1")
Application.ScreenUpdating = False
For Each rngC In myRng
ReDim Preserve myArr(myRng.Cells.Count - 1)
myArr(i) = rngC
i = i + 1
Next
With wksSource
'wksTarget.Range("M2").Resize(columnsize:=myRng.Cells.Count) = myArr
wksTarget.Columns.[8, 6, 4, 5, 3, 7, 2 ,10, 3] = myArr
End With
'wksSource.Range("C7:C18").Copy
' wksTarget.Range("X2").PasteSpecial Transpose:=True
'wksSource.Range("C33:C50").Copy
' wksTarget.Range("AJ2").PasteSpecial Transpose:=True
Application.ScreenUpdating = False
End Sub
wksTarget.Range("M2").Resize(columnsize:=myRng.Cells.Count) = myArr
I want his array from wksSource
Set myRng = Range("A2,A4,R20,C10,N2,O4,F8,H12,G14")
To workbook "Copy of long.xlsm"
wksTarget.Columns.[8, 6, 4, 5, 3, 7, 2 ,10, 3].End(xlUp)(2) = myArr
(translated to workable code of course)
Thanks.
Howard
Sub AbookToLong()
Dim myRng As Range, MyRng1 As Range
Dim rngC As Range
Dim i As Long
Dim myArr() As Variant
Dim wksSource As Worksheet, wksTarget As Worksheet
Dim wkbSource As Workbook, wkbTarget As Workbook
Dim rngSource As Range, rngTarget As Range
Set myRng = Range("A2,A4,R20,C10,N2,O4,F8,H12,G14")
Set wkbSource = Workbooks("Array cells to another workbook.xlsm")
Set wkbTarget = Workbooks("Copy of long.xlsm")
Set wksSource = wkbSource.Sheets("Sheet1")
Set wksTarget = wkbTarget.Sheets("Sheet1")
Application.ScreenUpdating = False
For Each rngC In myRng
ReDim Preserve myArr(myRng.Cells.Count - 1)
myArr(i) = rngC
i = i + 1
Next
With wksSource
'wksTarget.Range("M2").Resize(columnsize:=myRng.Cells.Count) = myArr
wksTarget.Columns.[8, 6, 4, 5, 3, 7, 2 ,10, 3] = myArr
End With
'wksSource.Range("C7:C18").Copy
' wksTarget.Range("X2").PasteSpecial Transpose:=True
'wksSource.Range("C33:C50").Copy
' wksTarget.Range("AJ2").PasteSpecial Transpose:=True
Application.ScreenUpdating = False
End Sub