+ Reply to Thread
Results 1 to 3 of 3

Macro to cut the 3 rows text in to a single row

Hybrid View

  1. #1
    Registered User
    Join Date
    03-06-2012
    Location
    chennai
    MS-Off Ver
    Excel 2003
    Posts
    34

    Thumbs up Macro to cut the 3 rows text in to a single row

    Hi Champs,

    I have attached a file which has input and output tab.
    The Input tab has data where a text of a specific row is split-ted across 2 or more than 2 rows.

    I need a macro for data to be exact as in Output tab. Thanks in Advance.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Macro to cut the 3 rows text in to a single row

    Hi,

    try: text2.xls

    contains:
    Option Explicit
    
    Private Sub cmdConvert_Click()
    Selection.Delete Shift:=xlToLeft
        Dim i As Long, lngMaxRows As Long
        Application.ScreenUpdating = False
        
        lngMaxRows = Cells(Rows.Count, 1).End(xlUp).Row
        
        For i = 2 To lngMaxRows
            If Not IsEmpty(Cells(i, 6)) Then
                MergeCells i, 2
            ElseIf Not IsEmpty(Cells(i, 5)) Then
                MergeCells i, 1
            End If
        Next i
        
        Application.ScreenUpdating = True
    End Sub
    
    Private Sub MergeCells(lngRow As Long, rpt As Integer)
        Dim i As Integer
        For i = 1 To rpt
            Cells(lngRow, 2).Value = Cells(lngRow, 2).Value & Cells(lngRow, 3).Value
            Cells(lngRow, 3).Delete Shift:=xlToLeft
        Next i
    End Sub
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Registered User
    Join Date
    03-06-2012
    Location
    chennai
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Macro to cut the 3 rows text in to a single row

    Hi Boss,

    Its working fine. Thanks a lot.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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