+ Reply to Thread
Results 1 to 18 of 18

Transfering data from sheet to another sheet using arrays

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Transfering data from sheet to another sheet using arrays

    Hello everybody
    I have two sheets : Data sheet and Results sheet
    My attachment is just a sample..the original has large amounts of data
    I could loop through cells in sheets("Data").range("b2:B" & Last row) to check for the date which is in Result sheet. range("C2") to extract the data related to that date

    I need to use arrays as I know it is faster and realiable in dealing with large amounts of data

    Thanks for help
    Attached Files Attached Files
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Transfering data from sheet to another sheet using arrays

    Hi there,

    Not sure why you can't just filter on the required dates within the Data tab, but this will do the job in the most efficient way nonetheless:

    Please Login or Register  to view this content.
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Transfering data from sheet to another sheet using arrays

    Thanks a lot Mr Robert for this simple and fantastic solution ..I really like it
    I'm learning new techniques and I know how to loop and how to use filter methods .. but I'm poor at arrays
    I was specific in post 1 that I need to learn how to do my task using arrays

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Transfering data from sheet to another sheet using arrays

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Transfering data from sheet to another sheet using arrays

    Mr. Jindon
    I tested the code on my original wb and the results are >>>>> great & fantastic & wonderful
    It's very speedy even faster than the filter method
    My way tooks about 20 seconds .. Filter way took about 7 seconds .. your way tooks about 2 seconds
    Thank you very much for this great help

    Just one request : can you add comments on the lines of the code to try getting it
    I liked the way Mr. Robert do when added comments on each line to explain how it works

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Transfering data from sheet to another sheet using arrays

    Step debug for yourself with LocalWindow open first.

    If you still need help, ask the lines that you don't understand....

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Transfering data from sheet to another sheet using arrays

    Thanks Mr. Jindon for guiding me
    As for this loop
    Please Login or Register  to view this content.
    I guess that loop to store the results that matches the criteria ..can I use another variable such as b for example to store the results in it
    to be like that I mean
    Please Login or Register  to view this content.
    and in this line
    Please Login or Register  to view this content.
    i tried to change but got an error
    I appreciate your help

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Transfering data from sheet to another sheet using arrays

    Then
    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Transfering data from sheet to another sheet using arrays

    Great Mr. Jindon
    i got it now
    In sheets("Data") in column A there are sometimes formulas
    Please Login or Register  to view this content.
    with no data related

    After chacking local window I found that there are empty elements of the array b stored in the array but they are empty ..
    how can I get rid of these empty elements?

    I'm sorry for all these questions but I'm learning from you

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Transfering data from sheet to another sheet using arrays

    Does it matter?

    I don't care when I use Array, looping inside array is almost nothing.
    I'd rather exit loop if the data column is "", like
    Please Login or Register  to view this content.

  11. #11
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Transfering data from sheet to another sheet using arrays

    Thanks a lot Mr. Jindon
    I have told you that I'm learning and I'm curious about details. That's all
    And from you now I learned new point which is that looping inside array is almost nothing (as I was intending to ask you about that point and you already replied me without asking you even)

    Last point to ask about : I have 15 columns in sheets("Data") and the required results are 14 columns ..
    In local window I noticed that array stored the 15 column but returns 14 column as needed .. but how the code let me get my results without any prompt in the code related to that point
    Hope it is clear

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Transfering data from sheet to another sheet using arrays

    That magic comes from
    Please Login or Register  to view this content.
    The sheet only has 14 columns so
    Please Login or Register  to view this content.
    is actually
    Please Login or Register  to view this content.
    You see?

  13. #13
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Transfering data from sheet to another sheet using arrays

    Yes now it is very very clear
    Thank you Mr Jindon for all these valuable information you provided me
    you are really great and distict person

    Can I ask again or you are annoyed from me?
    About Array b there are empty elements of the array even after adding this line
    Please Login or Register  to view this content.
    I'm talking about the results in local window ..Is it possible to ReDim array b according to the actual size !!?
    Last edited by YasserKhalil; 06-03-2015 at 06:59 AM.

  14. #14
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Transfering data from sheet to another sheet using arrays

    Hi YasserKhalil,
    . Here is another Array version similar to the last code I did for you.
    http://www.excelforum.com/excel-prog...ml#post4088104
    . It may be a bit slower than necessary as some additional steps are made to make it more clear to follow.
    . Also the Transpose is known to be slower than a simple routine to transpose Array.
    ( http://www.excelforum.com/showthread...t=#post4092919 )
    . Make note of jindon’s advice for putting watches on variable, especially the Arrays and watch how they are filled in when stepping through with F8. I find that easier when I have two screens,
    http://www.mrexcel.com/forum/lounge-...aneously.html?

    . Alan



    Code:

    Please Login or Register  to view this content.
    Last edited by Doc.AElstein; 06-05-2015 at 03:53 AM.
    '_- Google first, like this _ site:ExcelForum.com Gamut
    Use Code Tags: Highlight code; click on the # icon above,
    Post screenshots COPYABLE to a Spredsheet; NOT IMAGES PLEASE
    http://www.excelforum.com/the-water-...ml#post4109080
    https://app.box.com/s/gjpa8mk8ko4vkwcke3ig2w8z2wkfvrtv
    http://excelmatters.com/excel-forums/ ( Scrolll down to bottom )

  15. #15
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Transfering data from sheet to another sheet using arrays

    Thank you very very much Mr. Alan
    You are fantsatic .. I like your way of explaining all the details. That's very impressive and very useful
    Thanks alot for the time spent explaining the lines of the codes ...
    I learned a lot from your great explanation

  16. #16
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Transfering data from sheet to another sheet using arrays

    Quote Originally Posted by YasserKhalil View Post
    Thank you very very much Mr. Alan
    ...
    .


    Hi YasserKhalil,
    . Thanks for the feedback
    Alan Elston

    . BTW. ( By the way ) – I am looking also for my project in speeding things up a bit, possibly using Arrays. Amongst other things, I am considering a simple routine in place of the .Transpose Function. So I have as a by-product of this work another code version that you may wish to consider.. The basic form of the code is identical to that for my code from post #14. It is therefore in its more usually given, simplified form, and without most of the 'green comments
    . However the .Transpose part is replaced with a simple routine ( Placed in a Function for clarity of code layout. )
    .
    . Here the codes. ( You copy both codes to the same Module. But you only run the first Sub. This is because the Fuction is “called” when needed ( twice in this case from the first Sub ) ) . For the Fuction I have include my usual explaining 'green comments.

    Codes

    .
    Please Login or Register  to view this content.
    ………………

    . BTW. If you are testing all the above codes you have been given, along with yours and are comparing the speeds in large circuits it would be a great contribution to this Thread to Post your results. Post also a copy of your code attempt.. This would make this Thread a very useful one for future reference.

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Transfering data from sheet to another sheet using arrays

    Please Login or Register  to view this content.
    Pull rows that col.B match with criteria. No loop.

  18. #18
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Transfering data from sheet to another sheet using arrays

    Quote Originally Posted by jindon View Post
    Please Login or Register  to view this content.
    Pull rows that col.B match with criteria. No loop.
    . Wow! - And so fast - I will be busy most of tomorrow finding out how that works! (it does work ( Obvously ) - just ran it )
    .
    . I have a lot to learn
    .
    Alan
    Last edited by Doc.AElstein; 06-05-2015 at 06:13 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to use formula for transfering data from Tab Sheet 1 to Tab Sheet 2?
    By paulg100 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-30-2013, 03:14 AM
  2. How to use formula for transfering data from Tab Sheet 1 to Tab Sheet 2?
    By paulg100 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 12-29-2013, 01:24 AM
  3. Transfering data from one sheet to a master sheet using Submit (command button)
    By readitdaily in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-02-2013, 09:15 AM
  4. Transfering Data from Sheet to Sheet
    By Gary121 in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 09-25-2012, 08:47 PM
  5. Transfering data from Sheet to Sheet
    By Coors in forum Excel General
    Replies: 13
    Last Post: 11-14-2008, 05:00 PM

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