+ Reply to Thread
Results 1 to 4 of 4

VBA To enter certain data the concatenate cells in columns

  1. #1
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    VBA To enter certain data the concatenate cells in columns

    Hi, I have another challenge to overcome:

    I need to enter a certain range of data into a spreadsheet , then concatenate the cells, save the concatenated columns as values and then delete the columns that provided the original data. This is for recorded delivery postal tracking label serial numbers.

    Each batch of labels contains 100 labels. The serial numbers is composed of the following elements to be entered in the cells as follows:


    The format of the number is as follows, as they would be entered into the spread sheet

    A1 is 2 letters. These letters are the same for all labels in the batch and for some other batches I have, but it will change for future batches

    B1 is 4 digits. These numbers are the same for all labels in the batch and for one batche I have, but I have some newer batches that have a different number

    C1 is 4 digits. These numbers are sequential for each label in that particular batch If the batches are sequential to each other, these numbers should also continue sequentially across the batches

    D1 is a random 1 digit number. This has no discernable pattern so the number will always need to be entered manually

    E1 is 2 letters. these are ALWAYS "GB"


    Example Batches
    batch 1 has the series KS 3626 1202 3 GB to KS 3626 1301 5 GB

    batch 2 has the series KS 7314 0502 7 GB to KS 7314 0601 9 GB

    batch 3 has the series KS 7314 0602 2 GB to KS 7314 0701 4 GB

    batch 4 has the series KS 7314 0702 8 GB to KS 7314 0801 0 GB

    batch 5 has the series KS 7314 3802 5 GB to KS 7314 3901 7 GB

    batch 6 has the series KS 7314 3902 5 GB to KS 7314 4001 5 GB

    As you can see from the batch numbers, batch 1 is a very early batch; batches 2 to 4 are from recently issued batches and each batch is sequential. Batch 4 and 5 are from even more recently issued batches and each batch is sequential.

    So Row 1 will contain
    A1 = "KS" B1= "3626" C1="1202" D1="3" E1="GB" F1 is concatenated "KS362612023GB"
    Row 600 (if it can be done in one shot) will contain
    A600 = "KS" B600= "7314" C600="4001" D600="5" E6000"GB" F600 is concatenated "KS731440015GB"


    Ideally, I would like to do as much as possible by entering each of the serial number components once and then get the VBA to complete the cells and the concatenation.

    Presumably this would entail a snap box appearing for each of the cols, except D which will be manually entered, and col E which could be defaulted to value "GB"



    Using only batch 1 above as the example;

    Column A - Batch Length "100", Value "KS"

    Column B - Batch Length "100", Values "3626"

    Column C - Batch Length "100", Starting Value "1202" (so the last entry will be "1301")

    Column D - this will always be a random number that I will have to enter to every cell in the column

    Column E - Batch Length "100",This is ALWAYS "GB"


    In the above example I've processed 1 batch of 100 labels at a time, but I'm wondering if it could be made to take care of all the batches in one go. For future batches I'm hoping to get say 5 batches (500 labels) that have the same values for all rows in col A and all rows in col B and be fully sequential for col C



    After it has done all this, in col F it needs to concatenate the cells in A to E, then save as values which will enable cols A to E to be deleted, just leaving the concatenated column.


    Here's a basic "Record Macro" that I did to kick things off, but no doubt it will likely be of no use to you wizzes out there!!

    Please Login or Register  to view this content.

    I hope some or all of this can be done, but I don't have any workable knowledge of VBA to even know where to start...

    Thanks in anticipation / trepidation
    Kindest regards
    Mike

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA To enter certain data the concatenate cells in columns

    Try this:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: VBA To enter certain data the concatenate cells in columns

    Hi, thanks for the quick reply.

    Your code will concatenate the cells if I have previously entered all data into each of the 100 rows, but I was hoping that I could get a macro to complete the other 99 rows if I entered the first row manually.

    I now realise that before I run the macro I will have to type in all of col D manually as this is a random number with no recurring pattern to be able to automate it, but I would like to get the rest done by macro.

    So to recap, if row 1 col A to C was typed thus KS 3626 1202,

    Row 2 would look like KS 3626 1203,

    Row 3 would look like KS 3626 1204, etc etc.

    Your VBA puts the "GB" in col E so that would be retained as would the concatenation, save as, and col delete

    As previously noted I would have already have manually entered all 100 rows for Col D, so cols A and B are same values for all the rows and Col C is sequential from row A.

    Since sleeping on my first post I think it probably unrealistic to be able to do more than 100 rows at a time, not least due to the fact that I have to keep entering Col D manually. However if the macro could also be made to work on every row that has data in col D it would give me the flexibility to do more than 100 rows at a time.

    I would appreciate your further thoughts....

    Thanks again for your continuing help
    Kind regards
    mike

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA To enter certain data the concatenate cells in columns

    If you've entered the 100 D values:

    Please Login or Register  to view this content.

+ 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] Concatenate cells in 3 columns if value in question is found in another column
    By drgkt in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-14-2017, 07:46 AM
  2. [SOLVED] Concatenate data from cells by values from two columns
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-14-2016, 04:02 PM
  3. Replies: 2
    Last Post: 01-05-2015, 08:06 PM
  4. How to concatenate adjacent cells based on values present in previous columns?
    By Palraj in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-30-2014, 01:01 AM
  5. Concatenate 6 columns but exclude blank cells
    By shaz0503 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-05-2014, 11:28 PM
  6. Macro to concatenate cells in a range that skips empty columns
    By _lm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-17-2011, 03:53 PM
  7. Enter and highlight data in columns based on other columns
    By duugg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-13-2009, 09:48 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