Home > OS >  Moving data from worksheet 1 to a new worksheet in Excel
Moving data from worksheet 1 to a new worksheet in Excel

Time:01-08

Hope you all are well and had a lovely xmas break and new years!

I am trying to create a VBA code to move a data dump in Excel (extracted from PowerBI), to seperate new worksheets. So for example, below: Data dump example

if the Security Description, is the same, then all rows in the data dump to be copy and pasted into a new worksheet.

So the end result would be: Worksheet 1: Data Dump

Worksheet 2: All the rows from data dump which have Security Description "Security 1 - Description 1"

Worksheet 3: All the rows from data dump which have Security Description "Security 1 - Description 2"

Worksheet 4: All the rows from data dump which have Security Description "Security 2 - Description 1"

And so on for each unique Security Description.

Thank you! Best,

CodePudding user response:

This is how I would go about it:

  1. Store your data as an array. Let's call it OriginalArray.
  2. Create a new array for each combination of Security Description, Fund Name, Pool Name that you have.
  3. Iterate through all of the rows in OriginalArray and populate the respective arrays that you just created with the appropriate rows of data.
  4. Once the iteration is complete, write all of the arrays where you need them in your different worksheets.

I may have misunderstood what you are trying to do exactly, but even so, this should hopefully be enough to guide you.

CodePudding user response:

Any chance someone could help write the code please? I'm absolutely lost on how to use arrays. Best,

  •  Tags:  
  • Related