ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using an array to select data (https://www.excelbanter.com/excel-programming/312125-using-array-select-data.html)

Tony Barla

Using an array to select data
 
Hi All,

Im having trouble using an array to select data and transfer to another sheet.

I've created the array:
Sheets("Tmp Resource Sheet").Select
Range("A1").Select
myArray = Range(Selection, Selection.End(xlDown))

and now i need to transfer what is in the array to another sheet. The other
sheet has a named cell(Bdg_LadDays), where the data has to be transferred 2
cells below it.

For m = 0 To n ' n being the number of rows in the array
Range(Bdg_LabDays).Cells(m + 2, 0).Value = Range(myarray(m)).Value
Next m

The code to transfer the arrays contents doesn't work.
Can anyone please suggest a way for me to get this working.

Thanks.
Tony.



Erik BZ

Using an array to select data
 
Hi, try this code:

Sub TEST()

myarray = Range(Sheets("Tmp Resource Sheet").Range("A1"), Sheets("Tmp
Resource Sheet").Range("A1").End(xlDown))

For m = 1 To UBound(myarray)
Sheets("The other sheet").Range("Bdg_LabDays").Cells(m + 1, 1).Value =
myarray(m, 1)
Next m

End Sub

Best reg.,
Erik B

"Tony Barla" wrote in message
...
Hi All,

Im having trouble using an array to select data and transfer to another
sheet.

I've created the array:
Sheets("Tmp Resource Sheet").Select
Range("A1").Select
myArray = Range(Selection, Selection.End(xlDown))

and now i need to transfer what is in the array to another sheet. The
other
sheet has a named cell(Bdg_LadDays), where the data has to be transferred
2
cells below it.

For m = 0 To n ' n being the number of rows in the array
Range(Bdg_LabDays).Cells(m + 2, 0).Value = Range(myarray(m)).Value
Next m

The code to transfer the arrays contents doesn't work.
Can anyone please suggest a way for me to get this working.

Thanks.
Tony.





Tony Barla

Using an array to select data
 
You my friend, are a ledgend.
Thank you so much. I've been trying for hours to figure this out.

Thanks again.
Tony.

"Erik BZ" wrote:

Hi, try this code:

Sub TEST()

myarray = Range(Sheets("Tmp Resource Sheet").Range("A1"), Sheets("Tmp
Resource Sheet").Range("A1").End(xlDown))

For m = 1 To UBound(myarray)
Sheets("The other sheet").Range("Bdg_LabDays").Cells(m + 1, 1).Value =
myarray(m, 1)
Next m

End Sub

Best reg.,
Erik B

"Tony Barla" wrote in message
...
Hi All,

Im having trouble using an array to select data and transfer to another
sheet.

I've created the array:
Sheets("Tmp Resource Sheet").Select
Range("A1").Select
myArray = Range(Selection, Selection.End(xlDown))

and now i need to transfer what is in the array to another sheet. The
other
sheet has a named cell(Bdg_LadDays), where the data has to be transferred
2
cells below it.

For m = 0 To n ' n being the number of rows in the array
Range(Bdg_LabDays).Cells(m + 2, 0).Value = Range(myarray(m)).Value
Next m

The code to transfer the arrays contents doesn't work.
Can anyone please suggest a way for me to get this working.

Thanks.
Tony.






Alan Beban[_2_]

Using an array to select data
 
Tony Barla wrote:
Hi All,

Im having trouble using an array to select data and transfer to another sheet.

I've created the array:
Sheets("Tmp Resource Sheet").Select
Range("A1").Select
myArray = Range(Selection, Selection.End(xlDown))

and now i need to transfer what is in the array to another sheet. The other
sheet has a named cell(Bdg_LadDays), where the data has to be transferred 2
cells below it.

For m = 0 To n ' n being the number of rows in the array
Range(Bdg_LabDays).Cells(m + 2, 0).Value = Range(myarray(m)).Value
Next m

The code to transfer the arrays contents doesn't work.
Can anyone please suggest a way for me to get this working.

Thanks.
Tony.


Sheets("othersheet").Range("Bdg_LabDays")(3).Resiz e(UBound(myArray)).Value=myArray

Alan Beban


All times are GMT +1. The time now is 05:04 PM.

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