Results 1 to 4 of 4

Faced Problem while concentrate data with commas

Threaded View

  1. #1
    Registered User
    Join Date
    11-01-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    2

    Faced Problem while concentrate data with commas

    Hello to all experts,

    I am totally new in handling excel, vba and appreciate if someone could help me with the following problem which I am facing currently.

    I tried to transfer IDs with conditions fulfilled and concentrate them with commas to specific destination files, namely DestinationFile 2 and DestinationFile 3. However, I faced problem while transferring the data to one of the DestinationFile. Please view the images in the attached files, namely EndUser, DestFile2 and DestFile3 and you will see the image, named DestFile3 having an extra data of “xx4” circled in red.

    The following are the codes I used:


    1.For EndUser.xlsx

    Sub EndUser()
    
    Dim lr As Long
    Dim pr As String
    Dim dr As String
    Dim ar As String
    Dim br As String
    
    lr = Workbooks("EndUser.xlsx").Sheets("EndUser").Cells(Rows.Count, "B").End(xlUp).Row
            Workbooks("EndUser.xlsx").Activate
        
    If Workbooks("EndUser.xlsx").Sheets("EndUser").Range("D2") = "GL" Then
                ar = Workbooks("DestinationFile1.xlsx").Sheets("Sheet1").Range("B2").Value
        With Workbooks("EndUser.xlsx").Sheets("EndUser").Columns("A:B")
            .AutoFilter
            .AutoFilter Field:=2, Criteria1:=ar
            Range("A2:A" & lr).Copy
        End With
                Workbooks("DestinationFile1.xlsx").Activate
                Sheets("Sheet1").Range("A2").Select
                ActiveSheet.Paste
            
    ElseIf Workbooks("EndUser.xlsx").Sheets("EndUser").Range("D2") = "AP" Then
            ar = Workbooks("DestinationFile2.xlsx").Sheets("Sheet1").Range("B2").Value
        
        With Workbooks("EndUser.xlsx").Sheets("EndUser").Columns("A:B")
            .AutoFilter
            .AutoFilter Field:=2, Criteria1:=ar
            Range("A2:A" & lr).Copy
        End With
        
        Application.Run ("DestFile3")
        
        pr = Join(Application.Transpose(Range("A2:A" & lr)), ",")
        Workbooks("DestinationFile3.xlsx").Sheets("Sheet1").Range("A2").Value = pr
        
        Application.Run ("DestFile2")
        
        dr = Join(Application.Transpose(Range("A2:A" & lr)), ",")
        Workbooks("DestinationFile2.xlsx").Sheets("Sheet1").Range("A1").Value = dr
        
     End If
    
    Rows("1:1").Insert Shift:=xlDown
    Range("B2").Value = ar
       
            Do While Range("A3").Value <> ""
                Range("A3").EntireRow.Delete Shift:=xlUp
            Loop
    
        Windows("EndUser.xlsx").Activate
        Cells.AutoFilter
    End Sub
    2.DestinationFile 2

    Sub DestFile2()
    
            Workbooks("DestinationFile2.xlsx").Activate
            Sheets("Sheet1").Range("A2").Select
            ActiveSheet.Paste
            
    End Sub
    3.DestinationFile 3

    Sub DestFile3()
    
             Workbooks("DestinationFile3.xlsx").Activate
                Sheets("Sheet1").Range("A2").Select
                ActiveSheet.Paste
    End Sub
    Please kindly advise me in identifying my mistakes. All i want is that DestinationFile2 and 3's output will be the same.

    Appreciate all your help.
    Thank you in advance
    Regards,
    Pchng
    Attached Images Attached Images
    Last edited by royUK; 11-02-2010 at 02:13 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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