none
info in cell by macro write in different cells RRS feed

  • Question

  • Hello all,

    I got a cell in a file that contains the following

    WKK_01=Ja#WKK_25=#WKK_26=Kast LS#WKK_27=Type D#WKK_1=OK#WKK_40=#WKK_2=OK#WKK_41=#WKK_3=OK#WKK_42=#WKK_4=OK#WKK_43=#WKK_5=OK#WKK_44=#WKK_6=OK

    Now i need to put only the info after each = for each #WKK= the info in a different cell.

    How can i do this.

    thx you all

    Patrik

    Tuesday, February 21, 2017 10:54 AM

All replies

  • Hi Patrik Hooybergs,

    please use the code below.

    Sub demo()
     Dim strTest As String
       Dim strArray() As String
       Dim temp As String
       Dim intCount As Integer
       Dim i As Long
       
       strTest = "WKK_01=Ja#WKK_25=#WKK_26=Kast LS#WKK_27=Type D#WKK_1=OK#WKK_40=#WKK_2=OK#WKK_41=#WKK_3=OK#WKK_42=#WKK_4=OK#WKK_43=#WKK_5=OK#WKK_44=#WKK_6=OK"
       strArray = Split(strTest, "#")
       
       
       For intCount = LBound(strArray) To UBound(strArray)
          'Debug.Print (Trim(strArray(intCount)))
      
          For i = 1 To UBound(strArray) + 1
            temp = Trim(strArray(i - 1))
             Cells(i, 1).Value = Left(temp, InStr(temp, "="))
             Cells(i, 2).Value = Right(temp, (Len(temp) - InStr(temp, "=")))
        Next i
       Next
    
    End Sub

    Output:

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 22, 2017 12:42 AM
    Moderator