+ Reply to Thread
Results 1 to 9 of 9

Macro to duplicate lines changing cell value

  1. #1
    Registered User
    Join Date
    07-19-2011
    Location
    madrid, spain
    MS-Off Ver
    Excel 2003
    Posts
    5

    Post Macro to duplicate lines changing cell value

    Hi,

    Sorry if this has been already solved in some other thread but I've been unable to find it.

    Basically I have an spreadsheet with skus in column A (say 'baseball bat', 'baseball cap', 'baseball jacket'...) and a qty in column B (i.e. 300, 200, 150...).

    Is there a way to split row 1 'baseball bat' = 300 resulting in 8 rows (1 to 8) 'baseball bat' = 60, then row 2 (now row 9) 'baseball cap' = 200 in 4 rows 'baseball cap' = 50, and so on...

    Thank you.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Macro to duplicate lines changing cell value

    This can be done. But you need to explain on what basis do we create the duplicate rows? How do we know that baseball bat should be 8 rows and baseball cap should be 4 rows?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    07-19-2011
    Location
    madrid, spain
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Macro to duplicate lines changing cell value

    Thank you. I'm sorry. I would need resulting lines of 50 (300 = 6 lines not 8), (200 = 4 lines), (150 = 3 lines)... if I have, say, 125 I would need 50, 50, rest (25). Thank you so much again!!!!

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Macro to duplicate lines changing cell value

    Is there data only in columns A & B?

  5. #5
    Registered User
    Join Date
    07-19-2011
    Location
    madrid, spain
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Macro to duplicate lines changing cell value

    Sometimes there's a column C but I could enter that column after running the macro. Anyway if there're more columns they shouldn't change. Thanks!

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Macro to duplicate lines changing cell value

    Try this code
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose Tools | Macro | Macros
    Select a macro in the list, and click the Run button.

  7. #7
    Registered User
    Join Date
    07-19-2011
    Location
    madrid, spain
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Macro to duplicate lines changing cell value

    Thank you so so much for trying to help me!!!!! Nevertheless nothing happened when running the macro :-(
    See file attached!
    Attached Files Attached Files

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Macro to duplicate lines changing cell value

    The output is in sheet2. Sorry if i forgot to mention that.

  9. #9
    Registered User
    Join Date
    07-19-2011
    Location
    madrid, spain
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Macro to duplicate lines changing cell value

    thank you!!!!!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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