+ Reply to Thread
Results 1 to 8 of 8

Carrying an array to another sheet

  1. #1
    Registered User
    Join Date
    12-10-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    68

    Carrying an array to another sheet

    So I want to transfer selective data from "Sheet1" to "Sheet2". What I did was I just put the cells in "sheet1" I wanted, into that array.
    The array works fine (when I write it into cells) in "sheet1" from where its picking the data from but when I run that array in "sheet2" which is where I want to transfer the data to I get a "0" value.
    My question is does an array loses its data when its not used in its parent sheet ("sheet1") ?

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Carrying an array to another sheet

    No an array is independent of any worksheet.

    If you are losing data it might be for some other reason.

    Can you post your code?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-10-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Carrying an array to another sheet

    For I = 1 To (totalcol + 3)
    If Cells(4, I) = "Z-5" Then
    If Cells(7, I) = "GU" Then
    valarray(1) = Worksheets("Sheet1").Cells(12, I).Value
    valarray(2) = Worksheets("Sheet1").Cells(16, I).Value
    valarray(3) = Worksheets("Sheet1").Cells(17, I).Value
    valarray(4) = Worksheets("Sheet1").Cells(22, I).Value
    valarray(5) = Worksheets("Sheet1").Cells(26, I).Value
    End If
    End If
    Next I

    For k = 1 To 11
    If Worksheets("cop").Cells(20, k) = "2013" Then
    Worksheets("cop").Cells(21, k) = valarray(1)
    End If
    Next k

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Carrying an array to another sheet

    Why are you putting only the first item from the array into cells on 'cop'?

    If it is only one value you don't need an array.
    Last edited by Norie; 12-10-2012 at 03:15 PM.

  5. #5
    Registered User
    Join Date
    12-10-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Carrying an array to another sheet

    Sorry I didn't update my code. I need to put 5 values in "cop"

    For k = 1 To 11
    If Worksheets("cop").Cells(20, k) = "2013" Then
    For m = 2 To 5
    Worksheets("cop").Cells(21, k) = valarray(m)
    Next m
    End If
    Next k

  6. #6
    Registered User
    Join Date
    12-10-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Carrying an array to another sheet

    Thanks for the help! I wasnt selecting by data source. just needed to add Worksheets("sheet1").select at the top

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Carrying an array to another sheet

    No need to select.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    12-10-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Carrying an array to another sheet

    oh yaa, how could I forget haha! That makes sense. Thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1