none
how to split and concatenate the required fields in macros??? RRS feed

All replies

  • Let's say you read a line of the file into a string variable strLine.

    You can then use

        Dim arrParts As Variant
        ' Split the line into parts
        arrParts = Split(strLine, ",")
        ' Concatenate the bits you need
        strLine = arrParts(0) & "," & arrParts(2) & "," & arrParts(4)

    You can now use strLine the way you want.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Tuesday, July 12, 2016 2:04 PM
  • What is the logic of determining which fields to concatenate? And will your fields have spelling mistakes (assitant instead of assistant on the second line)? Most lines have 3 fields, and one line has 2....
    Tuesday, July 12, 2016 2:07 PM
  • sin/cosQ :)
    Wednesday, July 13, 2016 4:13 AM
  • tanQ sir will work out it and thanks for your support!!!!
    Wednesday, July 13, 2016 4:40 AM
  • Wednesday, July 13, 2016 8:22 AM
  • venerable sir,

    I already sent you a snapshot to you , I don't know how to rectify that issue please help me and thanks in advance!!!

    with regards,

    Parthiban A

    Wednesday, July 13, 2016 8:23 AM
  • hii, its just a example but what i need is to split the string in to several parts and I concatenate the parts which i want to join.....

    for e.g:

    hello,this,is,parthiban,from,india

    but i need only hello,india

    this,is,parthiban

    with regards,

    Parthiban A

     
    Wednesday, July 13, 2016 8:27 AM
  • It looks like you are trying to copy between two separate instances of Excel. If you want to keep the formulas, you must open both workbooks in the same instance of Excel.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Wednesday, July 13, 2016 11:28 AM
  • dim TmpArr() as string
    dim tmpStr as string
    dim ResultStr as string
    tmpStr  = "" '' set all the text you have shown in snap.
    
    TmpArr = vba.split(tmpstr, ",")
    
    '' joining text as you need from splited array 
    ResultStr  = TmpArr (0) & "," & TmpArr (2) & "," & TmpArr(4)



    Thanks and Regards, Software Developer Divyesh Makwana

    Wednesday, July 13, 2016 11:29 AM
  • Change the file extension to csv, and open the file with Excel, then delete the columns that you don't need.
    Wednesday, July 13, 2016 12:58 PM
  • tanQ sir!!!!
    Thursday, July 14, 2016 4:26 AM
  • Venerable sir, right now I am trying to  find out the formula in a excel sheet and I don't know how to explain my problem, as far as my understanding , In a excel sheet A column to D column contains a several maths formulas like (a+b)^2 , (a-b)^2 ,(a+b+c)^3, etc..... and what I want is, to copy the content of a cells which is containing the particular formula for e.g. (a+b)^2....Please help me to solve this sir, and I am waiting for your gracious reply!!!Thanks in advance:)

             

    Saturday, July 23, 2016 7:57 AM
  • This is a different question.  Please mark this as answered and start a new thread with the proper subject.
    Saturday, July 23, 2016 1:37 PM