+ Reply to Thread
Results 1 to 12 of 12

string concatenation

  1. #1
    Registered User
    Join Date
    10-16-2008
    Location
    bangalore
    Posts
    28

    string concatenation

    I have a string which contain spaces in between. I want all the spaces to be remove.

    Example: Say i have a string "IN DI A" and i want it to set as "INDIA".

    Can some help me on this using VB.

    I have 100 string to which spaces are to be removed and are to be kept in the same column.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    This will remove all the spaces in column A.

    Please Login or Register  to view this content.
    rylo

  3. #3
    Registered User
    Join Date
    10-16-2008
    Location
    bangalore
    Posts
    28

    thanks for prompt reply

    I have one more problem.

    If the data is in format as mentioned below:
    IN
    DIA

    and i want to be it as INDIA then how it is possible

  4. #4
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    In the same cell, or adjacent ones?

  5. #5
    Registered User
    Join Date
    10-16-2008
    Location
    bangalore
    Posts
    28

    same cell

    In the same cell.

  6. #6
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Which cell do you want it in, and what do you want to do with the data from the other cell?

    rylo

  7. #7
    Registered User
    Join Date
    10-16-2008
    Location
    bangalore
    Posts
    28

    information

    I have data in the cell C3,C5,C6 which is of the format,

    Cell C3:IN
    DIA

    Cell C5: D
    ELHI

    Cell C6: 12
    3

    I want these cells to be displayed as:

    Cell C3: INDIA , Cell C5: DELHI, Cell C6: 123.

  8. #8
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    This formula should do
    =TRIM(CLEAN(SUBSTITUTE(LEFT(TRIM(A7);LEN(TRIM(A7))-OR(RIGHT(TRIM(A7))={"?";"!";"."}));CHAR(160);" ")))
    ( from Ron de bruin's site)

    Replace ; with , as needed

  9. #9
    Registered User
    Join Date
    10-16-2008
    Location
    bangalore
    Posts
    28

    its not working properly

    its not working properly and giving some or the other compilation error.

  10. #10
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Please add a sample of your data in an XL sheet

  11. #11
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Hi,

    Try this in D3 and copy down

    =IF(C3="","",SUBSTITUTE(C3,CHAR(10),""))
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  12. #12
    Registered User
    Join Date
    10-16-2008
    Location
    bangalore
    Posts
    28

    Smile sample data

    the data to be accessed is:

    07AC
    TSTAT=1,07MSISDN=9848--,07PROFILE=127---,07SPID=227,07VMS_PWD=6885------,07LAN
    GUAGE=0,07SERV_TYPE=1-,07ANI_NR1=####################,07ANI_NR2=98481206--------

    the VB code is:
    Sub Split_String()

    Dim arTemp() As String
    Dim s1
    Dim s2
    Dim s3
    Dim i1

    Range("A2:D100").ClearContents
    Range("A1:D100").Replace what:=" ", replacement:=""

    arTemp = Split(Cells(1, 1), ",")
    For i1 = 0 To UBound(arTemp)
    s1 = Left(arTemp(i1), 2)
    s2 = Mid(arTemp(i1), 3, InStr(1, arTemp(i1), "=") - 3)
    s3 = Mid(arTemp(i1), InStr(1, arTemp(i1), "=") + 1, Len(arTemp(i1)))

    Cells(i1 + 2, 1) = "'" + s1
    Cells(i1 + 2, 2) = s2

    If Left(s3, 1) = 0 Then
    Cells(i1 + 2, 3) = "'" + s3
    Else
    Cells(i1 + 2, 3) = s3
    End If

    Next i1

    End Sub

    Please update me with the solution.
    Thanks to all.

+ 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. inputbox for simple verification purposes?
    By durandal05 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-08-2008, 06:03 PM
  2. vba code terminates without error
    By aseem in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-17-2008, 10:45 PM
  3. VBA Syntax for PDF
    By cvo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2007, 06:59 PM
  4. string concatenation
    By fanfan in forum Excel General
    Replies: 2
    Last Post: 09-14-2007, 03:09 PM
  5. processing a string by Excel
    By mark_neil2 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-20-2007, 07:35 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