• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Take data, replace function, execute marco, copy data and paste. Then loop

Status
Not open for further replies.

Do Duy

New Member
Hi all, please help me to solve this problem.

I have 1 file CSV and 1 file Summary excel. I need someone help me to make some action as below

Step 1 : Using Replace function to replace "*<OTA_AirLowFareSearchRQ" = "<OTA_AirLowFareSearchRQ" ( I just want to delete data before this tag).

Step 2 : Copy data from cell Q2 of CSV file

Step 3 : Paste in to sheet "sample" , cell B2 of excel file and run this marco

Code:
Sub Demo1()
With Worksheets("sample")
        SPQ = Split(Replace(.[B2].Value, ">", ">?"), "?")
         U& = UBound(SPQ)
    While R& < U
        If SPQ(R) Like "<*" Then
                     R = R + 1
        Else
            SPQ(R - 1) = SPQ(R - 1) & SPQ(R)
                     U = U - 1
            For N& = R To U:  SPQ(N) = SPQ(N + 1):  Next
        End If
    Wend
    For R = 0 To U - 1
        If SPQ(R) Like "</*" Then
                S$ = Left$(S$, Len(S$) - 2)
            SPQ(R) = S & SPQ(R)
        Else
                ST = Split(SPQ(R), "<")
            SPQ(R) = S & SPQ(R)
            If Not (SPQ(R) Like "*/>" Or ST(UBound(ST)) Like "/*") Then S = S & "  "
        End If
    Next
        .[E2].Resize(U).Value = Application.Transpose(SPQ)
End With
End Sub

Step 4 : copy all data after process from cell E2 -> end data from sheet "sample" to cell G1 of sheet "process"
Step 5 : run marco in sheet "process"
Step 6 : paste precessed data to cell E8 of sheet "Summary"
Step 7 : Loop from step 2 with cell Q3 and paste processed data to F8...and so on

Thank.
 

Attachments

  • sample.xlsm
    81.1 KB · Views: 0
  • search_result 8IS6.zip
    171.1 KB · Views: 0
Last edited:
Status
Not open for further replies.
Back
Top