Results 1 to 9 of 9

Not getting correct output problem

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Not getting correct output problem

    Hi friends,
    I want to concatenate the 3 different columns in column 'g, ac and ad' respectively. I'm not getting the correct output in column 'g' and the concatenate output of column 'ac and ad' respectively. The output of concatenate 'ac and ad' displays in a single column 'g' and the concatenate output of column 'g' is not displaying in column 'g'.

    Please see the following code and suggest me the correction to get correct output.

    Option Explicit
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    With Target
      If .Count = 1 Then
        Select Case .Column
            
                                                         Case 28 'Column AB
                                                         On Error Resume Next
            Range("b" & .Row + 1).Select
            On Error GoTo 0
            
            Case 6 'Column F
                    On Error Resume Next
            Target.Offset(, 2).Select         'This will select the next column to the right from the changed cell
            On Error GoTo 0
            
            Case 13 'Column M
                    On Error Resume Next
            Target.Offset(, 2).Select         'This will select the next column to the right from the changed cell
            On Error GoTo 0
                    
                    
                    End Select
                    End If
                    End With
    
    'CONCATENATE column g
    
    If Target.Row < 7 Then Exit Sub
    Dim vTemp As Variant
    Dim var As Variant
    Dim lngArr As Long
    
    var = Array("C", "d", "e", "f")
    
    Application.EnableEvents = False
    
    For lngArr = LBound(var) To UBound(var)
      vTemp = vTemp & Cells(Target.Row, var(lngArr)).Value & " "
    Next lngArr
    vTemp = Replace(Trim(vTemp), "-", " ")
    Cells(Target.Row, 7).Value = vTemp
    
    Application.EnableEvents = True
    
    'CONCATENATE column ac
    
    If Target.Row < 7 Then Exit Sub
    
    var = Array("z", "aa", "ab")
    
    Application.EnableEvents = False
    
    For lngArr = LBound(var) To UBound(var)
      vTemp = vTemp & Cells(Target.Row, var(lngArr)).Value & " "
    Next lngArr
    vTemp = Replace(Trim(vTemp), "-", " ")
    Cells(Target.Row, 7).Value = vTemp
    
    Application.EnableEvents = True
    
    'CONCATENATE column ad
    
    If Target.Row < 7 Then Exit Sub
    
    var = Array("aa", "ab")
    
    Application.EnableEvents = False
    
    For lngArr = LBound(var) To UBound(var)
      vTemp = vTemp & Cells(Target.Row, var(lngArr)).Value & " "
    Next lngArr
    vTemp = Replace(Trim(vTemp), "-", " ")
    Cells(Target.Row, 7).Value = vTemp
    
    Application.EnableEvents = True
    
    End Sub
    Thanking you in anticipation.

    Regards,

    Mukesh
    Last edited by mukeshbaviskar; 02-19-2014 at 03:02 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Error in sum formula not correct output
    By mukeshbaviskar in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-31-2014, 11:40 AM
  2. [SOLVED] Not getting correct output value( Label & (i-6) & .Top)
    By annpricks in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-31-2012, 03:44 AM
  3. Find and output correct path
    By 9437excel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-07-2011, 02:20 PM
  4. problem with CSV output
    By duxis in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-21-2008, 06:16 AM
  5. Month Function Not Displaying Correct Output?
    By NewExcelUser in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-29-2007, 03:50 PM

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