+ Reply to Thread
Results 1 to 3 of 3

Multiple occurrences of a character on a single cell to be copied

Hybrid View

Excelhelpss Multiple occurrences of a... 06-18-2015, 09:19 AM
Special-K Re: Multiple occurrences of a... 06-18-2015, 10:05 AM
Excelhelpss Re: Multiple occurrences of a... 06-18-2015, 10:34 AM
  1. #1
    Registered User
    Join Date
    06-17-2015
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    3

    Multiple occurrences of a character on a single cell to be copied

    Hi,

    Need your help on this:

    I have the following text in Cell A1:

    M4.CTC.VA03.Verify Sales Documents.v2 [14294];
    M4.CTC.VK11.Create List Price By Customer Groups.v1 [6317];
    M4.CTC.VA03.Verify Sales Documents.v2 [14295]

    I would like to copy the following in Cell A2:

    [14294]; [6317]; [14295]

    There are thousand of rows and each row has multiple lines of text. some has 2 lines some has 10...

    Please help!!

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,077

    Re: Multiple occurrences of a character on a single cell to be copied

    In a blank sheet copy your data to column A

    Enter this VBA

    Sub k1()
    LastRow = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
    For i = 1 To LastRow
    k = Cells(i, 1)
    l = ""
    For j = 1 To Len(k)
    If m = 1 Then
        l = l & Mid(k, j, 1)
    End If
    If Mid(k, j, 1) = "]" Then
        m = 0: l = l & "; "
    End If
    If Mid(k, j, 1) = "[" Then
        m = 1: l = l & "["
    End If
    Next j
    l = Left(l, Len(l) - 2)
    Cells(i, 2) = l
    Next i
    End Sub
    Column B will contain the results
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    06-17-2015
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    3

    Re: Multiple occurrences of a character on a single cell to be copied

    Thanks for replying Special-k. However, I am getting error on line 17 Column 1 i.e. where the code says:

    l = Left(l, Len(1) - 2)

    I have copied your code and pasted it as you have explained.

+ 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] replace nth occurrences of a character string within a cell...
    By herbie226 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-09-2014, 02:50 AM
  2. [SOLVED] In a single cell, count any occurrences from a list of values
    By daedelous00 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-05-2013, 03:30 PM
  3. [SOLVED] More than 30000 data copied to a single cell
    By maez08 in forum Excel General
    Replies: 1
    Last Post: 10-08-2012, 10:57 PM
  4. Replies: 5
    Last Post: 11-19-2010, 03:49 PM
  5. Replies: 4
    Last Post: 01-22-2005, 12:06 AM

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