+ Reply to Thread
Results 1 to 13 of 13

Macro to split a cell data into rows and copying other cells as it is in rows

Hybrid View

  1. #1
    Registered User
    Join Date
    11-08-2010
    Location
    PUNE, INDIA
    MS-Off Ver
    Excel 2007
    Posts
    13

    Macro to split a cell data into rows and copying other cells as it is in rows

    Plz find the attachement in which there are some cell in column D which have data like S22A/S22B/S22C/S22D or BS12/BS17/BS07/BS03 like that to split these in row and also to copy the data of other row & column.
    Attached Files Attached Files
    Last edited by shaan65; 11-26-2010 at 12:46 AM.

  2. #2
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Macro to split a cell data into rows and copying other cells as it is in rows

    shaan65,

    Received your Private Message.


    Detach/open workbook SplitDataV2 - shaan65 - EF754025 - SDG13.xls and run macro SplitDataV2.


    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.
    Attached Files Attached Files
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  3. #3
    Registered User
    Join Date
    11-08-2010
    Location
    PUNE, INDIA
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Macro to split a cell data into rows and copying other cells as it is in rows

    thanks brother

  4. #4
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Macro to split a cell data into rows and copying other cells as it is in rows

    shaan65,

    You are welcome.

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.

  5. #5
    Registered User
    Join Date
    11-08-2010
    Location
    PUNE, INDIA
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Macro to split a cell data into rows and copying other cells as it is in rows

    Hi,

    Thanks a ton for your very quickreply. However, an implication exists herein running
    this macro considering this below scenario. Suppose, I have 100 Workssheets in a
    single Xlssheet. Should I run same macro for each and evey sheet seperately so it
    results100 Sheets that is a tiresome task. Could you please update that produce the
    results in 1Go?

    Also, in the macro i want that what ever the changes we are making through macro should be highlighted or shaded in different colour.

    for reference you can take my earlier attachment which has two sheets i want the same macro for the both sheets which should also highlight the changes and work for both sheets.

    Regards,
    Shankar

  6. #6
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Macro to split a cell data into rows and copying other cells as it is in rows

    shaan65,

    The following macro will cycle thru all the worksheets in the workbook.


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


    
    Option Explicit
    Sub SplitDataV3()
    ' stanleydgromjr, 11/22/2010, EF754025
    Dim c As Range, firstaddress As String, Sp, a As Long
    Dim ws As Worksheet
    Application.ScreenUpdating = False
    For Each ws In ThisWorkbook.Worksheets
      With ws
        With ws.Columns(4)
          firstaddress = ""
          Set c = .Find("*/*", LookIn:=xlValues, LookAt:=xlWhole)
          If Not c Is Nothing Then
            firstaddress = c.Address
            Do
              Sp = Split(c, "/")
              a = UBound(Sp)
              c.Offset(1).Resize(a).EntireRow.Insert
              ws.Range("B" & c.Row & ":L" & c.Row).Copy ws.Range("B" & c.Row + 1 & ":B" & c.Row + a)
              c.Resize(a + 1).Value = Application.Transpose(Sp)
              ws.Range("B" & c.Row & ":B" & c.Row + a).RowHeight = 12.75
              ws.Range("B" & c.Row & ":L" & c.Row + a).Interior.ColorIndex = 6
              Set c = .FindNext(c)
              On Error Resume Next
            Loop While Not c Is Nothing And c.Address <> firstaddress
            On Error GoTo 0
          End If
        End With
      End With
    Next ws
    Application.ScreenUpdating = True
    End Sub

    Then run the SplitDataV3 macro.

+ Reply to Thread

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