+ Reply to Thread
Results 1 to 9 of 9

How to assign an ID to a batch of copied data

  1. #1
    Registered User
    Join Date
    10-23-2019
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    14

    How to assign an ID to a batch of copied data

    Hi Folks

    would be eternally greatful for any wisdom! apologies in advance i'm new to VBA

    Essentially i need to copy multiple batches of data from one sheet to another sequentially which is easy enough but i need to add an ID to the Columns after the batch to signify which Batch, so it would be

    Copy Batch 1 from Sheet one and paste in sheet 2 Add with an identifier of 1

    Copy Batch 2 from Sheet one and paste in sheet 2 directly under the Batch 1 data but with and Identifier of 2

    below is the code for copying batch 1 how do i give it an identifier at the end of the row, also the batches change in size(number of rows all the time) Columns Stay the same, so it would need to be dynamic

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Data File for Unpacking.xlsx
    Last edited by AliGW; 09-26-2023 at 03:13 AM. Reason: Code tags added - please review the forum guidelines.

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: How to assign an ID to a batch of copied data

    This is easy enough to do, but far easier if we could see an example workbook. Any chance you could attach a desensitised version for us to work with?

    With a sample workbook we could also see how you're copying and pasting the subsequent batches and more than likely tidy your code up a little for you.

    BSB

  3. #3
    Registered User
    Join Date
    10-23-2019
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    14

    Re: How to assign an ID to a batch of copied data

    Thanking you!

    I should give more context with the file, i essentially have a lot of data which is aggregated based on Packed Data column O.. essentially need to create a new Unpacked tab where it's separated out by rep. so Rep 1 appears in 4311 rows copy that into the Unpack sheet and same with Rep 2 and Rep 3 etc

    My code is essentially filtering value 1 on columns P, Q & R respectively and just copying...but then i need an additional identifier in order to signify that this row is relating to Rep 1, 2 or 3 in particular....just for reference in the real data set there are 20 reps with way less rows but this is just the desensitised version i could come up with...happy to assist on further details

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: How to assign an ID to a batch of copied data

    So, for clarification, the data is filtered based on column O to anything that contains "Rep 1", those rows are copied to the other sheet and a 1 is added to the last column. Then the same for Rep 2 and Rep 3 etc., even if those rows already exist on the other sheet?

    BSB

  5. #5
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: How to assign an ID to a batch of copied data

    Also, does your real data actually say Rep 1, Rep 2 etc., or does it have actual rep names?

    BSB

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: How to assign an ID to a batch of copied data

    Depending on your answers to my questions above, the below code could work for you.
    Please Login or Register  to view this content.
    BSB

  7. #7
    Registered User
    Join Date
    10-23-2019
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    14

    Re: How to assign an ID to a batch of copied data

    That is correct and yes they would be actual names
    Last edited by coombs994; 09-25-2023 at 05:02 PM.

  8. #8
    Registered User
    Join Date
    10-23-2019
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    14

    Re: How to assign an ID to a batch of copied data

    I'm afraid I get the below error?


    Attachment 843886

  9. #9
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,563

    Re: How to assign an ID to a batch of copied data

    Selecting attachment 843886 results in the following: "Invalid Attachment specified. If you followed a valid link, please notify the administrator".
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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. Replies: 7
    Last Post: 06-27-2023, 10:30 AM
  2. Assign which column to paste the copied data VBA
    By mikuhatsune01 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2020, 06:11 AM
  3. Replies: 4
    Last Post: 06-07-2017, 10:44 AM
  4. Get External Data from Web - Batch request - skip if no data is retrieved from webpage
    By cooper.1651 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-18-2014, 12:44 PM
  5. [SOLVED] When data is copied to another workbook, hyperlinks as not copied or they don't work
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-17-2014, 06:46 AM
  6. [SOLVED] Formula to round down on a batch and exclude anything under a full batch
    By toomuchbrew in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-15-2012, 11:04 AM
  7. Replies: 0
    Last Post: 06-19-2012, 11:36 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