WISDOMBYDATA
  • BLOG
    • Blog Guide
    • Blog History
  • EXCEL
    • Functions & Formulas
    • VBA & Macros
    • VLOOKUP
    • Pivot Tables
    • Conditional Formatting
    • Tricks & Shortcuts
  • BI
    • SAP BOBJ/BW
    • Tableau
  • SQL
  • ABOUT
    • About WBD
    • About Me

Inserting Duplicate Rows Based on Numeric Values in a column

8/19/2014

3 Comments

 

The purpose of this blog post is to illustrate how to create duplicate rows based on numeric values indicated for each unique row value. Consider the table below depicting status of test cases and the number of test cases which have a particular status:  
Picture
We want to take the view above and create duplicate rows for each value in the “Status of Test Cases” column based on their respective numeric value in the “# of Test Cases” column (In a real life scenario doing so may be needed in order to insert a test case number for each test case). The following is what is wished to be achieved:
Picture
The traditional way of achieving the above is to insert the additional wanted rows manually. This may seem rather simple for the example above, however; imagine if we were dealing with two digit, three digit or even larger numbers. In that case inserting the extra rows manually would become a very time consuming and daunting task.

In this blog post I will teach you how to perform this task manually by utilizing Excel’s Macros function. These six steps will reach you to the desired results:

Step 1] Ensure that you Place your data in the correct columns in Excel: columns A and B respectively.
Picture
Step 2] Push “ALT+F11”
Step 3] Go to Insert > Module
Picture
Step 4] Paste the code located within the Notepad document below into the module page:
full_macro.txt
File Size: 0 kb
File Type: txt
Download File

Step 5] Push "ALT+F11"
Step 6] Push "ALT+F8" and press “Run” in the window below:
Picture
Here is the end result. That was unbelievably simple!
Picture

3 Comments
Rocky
9/28/2017 03:12:38 pm

This is very awesome.
If you wanted to copy multiple columns, how would that work?

Example:
Column A:J contains data. Column K is your "# of Test Cases"

I adjusted the letters in the VB code but couldn't do this.

Reply
Mehran
3/25/2018 09:05:56 pm

Hi Rocky,

I have addressed your query in my latest blog post. you can view it through the link below:

http://www.mehranvahedi.com/my-blog

Reply
Mehran
3/25/2018 09:06:40 pm

http://www.mehranvahedi.com/my-blog/inserting-duplicate-rows-from-multiple-columns-based-on-numeric-values-in-a-column




Leave a Reply.

    Categories

    All
    BI
    EXCEL
    MISC
    SQL

    Archives

    June 2020
    May 2020
    April 2020
    March 2020
    February 2020
    December 2019
    November 2019
    October 2019
    September 2019
    August 2019
    July 2019
    June 2019
    May 2019
    April 2019
    March 2019
    February 2019
    January 2019
    December 2018
    November 2018
    October 2018
    September 2018
    August 2018
    July 2018
    June 2018
    May 2018
    April 2018
    March 2018
    September 2017
    August 2017
    July 2017
    June 2017
    May 2017
    April 2017
    March 2017
    February 2017
    January 2017
    December 2016
    November 2016
    October 2016
    September 2016
    August 2016
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    February 2016
    May 2015
    April 2015
    March 2015
    February 2015
    January 2015
    December 2014
    November 2014
    October 2014
    September 2014
    August 2014
    April 2014
    March 2014
    February 2014
    January 2014
    December 2013
    November 2013

Powered by Create your own unique website with customizable templates.
  • BLOG
    • Blog Guide
    • Blog History
  • EXCEL
    • Functions & Formulas
    • VBA & Macros
    • VLOOKUP
    • Pivot Tables
    • Conditional Formatting
    • Tricks & Shortcuts
  • BI
    • SAP BOBJ/BW
    • Tableau
  • SQL
  • ABOUT
    • About WBD
    • About Me