+ Reply to Thread
Results 1 to 5 of 5

Copy data into multiple rows using macros and insert zero

  1. #1
    Registered User
    Join Date
    04-21-2014
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    2

    Copy data into multiple rows using macros and insert zero

    Hi All,

    I'm new to Macros and below is my requirement.I need to split my data into multiple rows based on count
    and the first row should have the value but the other rows should have a value as zero

    Input

    Count Value
    1 400
    2 101
    3 300
    4 450

    Output

    Count Value
    1 400
    2 101
    2 0
    3 300
    3 0
    3 0
    4 450
    4 0
    4 0
    4 0

    Any advise

    Thanks in advance

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Copy data into multiple rows using macros and insert zero

    Hi, DeepthiBas9,

    maybe like this (please use a copy of the worksheet for testing and adapt the ranges as needed):

    Please Login or Register  to view this content.
    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Copy data into multiple rows using macros and insert zero

    Try this:

    InsertRows.xlsm
    1. Reply to thread and inform if suggestion was helpful or not
    2. Click on the star (=Add Reputation) if you think someone helped you
    3. Mark [SOLVED] to this thread if solution was found. (On Menu "Thread Tools" > "Mark this thread as solved")

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy data into multiple rows using macros and insert zero

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-21-2014
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Copy data into multiple rows using macros and insert zero

    Thank You so much everyone for your quick responses!!

+ 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. [SOLVED] Macro - copy and insert multiple rows
    By yedry101 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-09-2013, 06:25 PM
  2. Macros to insert 2 blank row and autosum a column after every 200 rows in data range.
    By sachinsingh in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-22-2013, 09:55 AM
  3. [SOLVED] Insert Multiple Rows Based Off Number in Cell and Copy Data From Above New Rows
    By tstell1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-02-2012, 04:15 PM
  4. Macros to insert row& copy formula on multiple sheets
    By Mysore in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-19-2012, 08:12 PM
  5. Copy paste data, insert rows, insert data and change . to -
    By xWiZardx in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-16-2010, 01:44 AM

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