I want to write code to look through a large sheet and pull in certain data.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kyle Pellum
    New Member
    • Jul 2010
    • 3

    I want to write code to look through a large sheet and pull in certain data.

    I am trying to write a code to look through one column of a large worksheet pulling in data from that sheet in to others. What I have is a column titled "sector" I want the code to loop through this column and seperate the like values. I then want it to pull the data based on each sector in the worksheets I have created for them.

    For ex. the sector column includes things like U.S. Treasury, FNMA, and GNMA. I was to use vba to seperate each of these onto their respective worksheet.

    Thanks.
  • Kyle Pellum
    New Member
    • Jul 2010
    • 3

    #2
    The Spreadsheet I am working with.

    Just wanted to attach the spreadsheet to give a better idea.
    Attached Files

    Comment

    • Guido Geurs
      Recognized Expert Contributor
      • Oct 2009
      • 767

      #3
      The idea is:
      1st - find all the different values for "sector" and put them in an ARRAY.
      2nd - find in the rows of data, for each value (sector) of the first array, and put them in a second ARRAY.
      Dump the last array in the corresponding sheet.

      There are calls in BYTES in which data is sorted into sheets like:
      "Form data not going to correct date tab" from vbanewbie2

      Comment

      • Guido Geurs
        Recognized Expert Contributor
        • Oct 2009
        • 767

        #4
        I hope this will help You (see attachment)
        Run the macro "Filter_Dat a"
        Attached Files

        Comment

        • Guido Geurs
          Recognized Expert Contributor
          • Oct 2009
          • 767

          #5
          I'm sorry but there was an error in the code.
          I hope this is the right one: see attachment

          PS:
          I have also added a "report" sheet with the number of records copied to the sheets.

          The Data sheet is modiffied in this workbook because I wanted to do a test with sectors with only 1 row of data.
          Excel was giving an error when there was only 1 row data in a collection sheet with several "sectors".
          Attached Files

          Comment

          Working...