H
Howard
Sub Fill_Array_This_One works just fine, returns a Value, Text or cell reference from the sheet to range A1:A10.
Sub Fill_Array_That_One is an attempt to gather data from a 'scattered' array (cell references) and copy them to another 'scattered' array on the sheet.
It errors out at the line below '**.
Sub Using_Now works fine and brings me to my questions:
Is there any reason to try to use an Array copied to an Array sub instead of the Using_Now sub?
If so, how do I make Sub Fill_Array_That_One work correctly?
Thanks,
Howard
Option Explicit
Sub Fill_Array_This_One()
' Works okay
Dim myarray As Variant
myarray = Array(1, 2, "Kitty", 4, 5, Range("J2"), 7, 8, "Doggie", Range("N5"))
Range("A1:A10").Select
Range("A1:A10").Value = Application.WorksheetFunction.Transpose(myarray)
End Sub
Sub Fill_Array_That_One()
' ** Does not work
Dim myarray As Variant
Dim a, b, c, d, e, f As Variant
a = Range("J2")
b = Range("J5")
c = Range("L2")
d = Range("L5")
e = Range("N2")
f = Range("N5")
myarray = Array(a, b, c, d, e, f)
'** Wrong number of arguments or Invalid property assignment
Range("B8", "C10", "D12", "E1O", "F8", "D7").Select
Range("B8", "C10", "D12", "E1O", "F8", "D7").Value = Application.WorksheetFunction.Transpose(myarray)
End Sub
Sub Using_Now()
Sheets("Input").Range("F13").Copy Sheets("Data").Range("F3")
Sheets("Input").Range("F16").Copy Sheets("Data").Range("C3")
Sheets("Input").Range("F19").Copy Sheets("Data").Range("D3")
Sheets("Input").Range("I13").Copy Sheets("Data").Range("I3")
Sheets("Input").Range("I16").Copy Sheets("Data").Range("J3")
Sheets("Input").Range("I19").Copy Sheets("Data").Range("M3")
Sheets("Input").Range("L13").Copy Sheets("Data").Range("O3")
Sheets("Input").Range("K17").Copy Sheets("Data").Range("AB3")
Sheets("Input").Range("I13,F13,F16,F19,I19,I16,M13,L13").ClearContents
End Sub
Sub Fill_Array_That_One is an attempt to gather data from a 'scattered' array (cell references) and copy them to another 'scattered' array on the sheet.
It errors out at the line below '**.
Sub Using_Now works fine and brings me to my questions:
Is there any reason to try to use an Array copied to an Array sub instead of the Using_Now sub?
If so, how do I make Sub Fill_Array_That_One work correctly?
Thanks,
Howard
Option Explicit
Sub Fill_Array_This_One()
' Works okay
Dim myarray As Variant
myarray = Array(1, 2, "Kitty", 4, 5, Range("J2"), 7, 8, "Doggie", Range("N5"))
Range("A1:A10").Select
Range("A1:A10").Value = Application.WorksheetFunction.Transpose(myarray)
End Sub
Sub Fill_Array_That_One()
' ** Does not work
Dim myarray As Variant
Dim a, b, c, d, e, f As Variant
a = Range("J2")
b = Range("J5")
c = Range("L2")
d = Range("L5")
e = Range("N2")
f = Range("N5")
myarray = Array(a, b, c, d, e, f)
'** Wrong number of arguments or Invalid property assignment
Range("B8", "C10", "D12", "E1O", "F8", "D7").Select
Range("B8", "C10", "D12", "E1O", "F8", "D7").Value = Application.WorksheetFunction.Transpose(myarray)
End Sub
Sub Using_Now()
Sheets("Input").Range("F13").Copy Sheets("Data").Range("F3")
Sheets("Input").Range("F16").Copy Sheets("Data").Range("C3")
Sheets("Input").Range("F19").Copy Sheets("Data").Range("D3")
Sheets("Input").Range("I13").Copy Sheets("Data").Range("I3")
Sheets("Input").Range("I16").Copy Sheets("Data").Range("J3")
Sheets("Input").Range("I19").Copy Sheets("Data").Range("M3")
Sheets("Input").Range("L13").Copy Sheets("Data").Range("O3")
Sheets("Input").Range("K17").Copy Sheets("Data").Range("AB3")
Sheets("Input").Range("I13,F13,F16,F19,I19,I16,M13,L13").ClearContents
End Sub