+ Reply to Thread
Results 1 to 2 of 2

Use VBA to copy sheet number of times based on cell?

Hybrid View

  1. #1
    Registered User
    Join Date
    05-25-2017
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    1

    Use VBA to copy sheet number of times based on cell?

    I have a simple excel sheet, 8 cells:

    PO#
    ###
    Item #
    ###
    Pieces
    ##
    Carton #

    Is there a vba formula that will copy all of the cells and paste into seperate sheets based on the pieces cell? For example if there are 8 peices, then it would output 8 sheets and increment the carton # from 1 through 8 on each sheet?

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Use VBA to copy sheet number of times based on cell?

    Something like this perhaps.
    Sub Duplicate()
    Dim wsMain As Worksheet
    Dim wsNew As Worksheet
    Dim CartonNo As Long
    
        Set wsMain = Sheets("Sheet1")
        
        For CartonNo = 1 To wsMain.Range("A6").Value
            wsMain.Copy After:=Sheets(Sheets.Count)
            Sheets(Sheets.Count).Range("A8").Value = CartonNo
        Next CartonNo
        
    End Sub
    If posting code please use code tags, see here.

+ 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. Copy and Paste Cell X number of times based on Adjacent Cell
    By GabeGabe in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-07-2016, 11:40 AM
  2. [SOLVED] Copy paste data number of times based on cell value
    By shreeja178 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-19-2016, 06:19 AM
  3. Copy a row and paste it a number of times based on a cell value
    By glrubens in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-02-2013, 12:37 PM
  4. Replies: 0
    Last Post: 05-18-2012, 11:18 PM
  5. Copy a cell to another sheet N number of times Excel 2007
    By kowshick in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-16-2011, 03:13 PM
  6. VBA; copy paste number of times based on cell value
    By photopidge in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-25-2011, 03:17 AM
  7. copy sheet a # of times based on cell value
    By nuver in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2005, 03:34 PM

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