+ Reply to Thread
Results 1 to 6 of 6

VBA to split report according to segmentation of rows unique values to sheet check

Hybrid View

johnlara VBA to split report according... 06-20-2016, 03:49 PM
jaslake Re: VBA to split report... 06-20-2016, 06:22 PM
johnlara Re: VBA to split report... 06-21-2016, 08:34 AM
jaslake Re: VBA to split report... 06-21-2016, 10:44 AM
johnlara Re: VBA to split report... 06-23-2016, 02:20 AM
jaslake Re: VBA to split report... 06-23-2016, 08:09 AM
  1. #1
    Forum Contributor
    Join Date
    04-30-2013
    Location
    washington
    MS-Off Ver
    Excel 2019
    Posts
    168

    VBA to split report according to segmentation of rows unique values to sheet check

    Dear experts

    i have set of range data along with end of splitting values column AA

    where values is unique rows get split as different segment header in sheet check

    like under column AA no 27 where as text value is split rows data under corresponding segment values header

    every segment of splited rows above FY-16 Business Entity Report for the & splitunique value collection,dispute,dues....etc

    find the attachment
    Attached Files Attached Files

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA to split report according to segmentation of rows unique values to sheet check

    Hi John

    This Code is inModule1 of the attached and appears to do as you require...
    Option Explicit
    
    Sub Split_Column_AA()
       Dim ws           As Worksheet
       Dim ws1          As Worksheet
       Dim LR1          As Long
       Dim i            As Long
       Dim Rng          As Range
    
       
       Application.ScreenUpdating = False
       Set ws = Sheets("LOB")
       If Not Evaluate("ISREF(Output!A1)") Then
          Worksheets.Add(After:=ws).Name = "Output"
       Else
          Sheets("Output").Cells.Clear
       End If
    
       Set ws1 = Sheets("Output")
    
       ws.Cells.Copy
       ws1.Range("A1").PasteSpecial
       With ws1
          LR1 = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                            SearchDirection:=xlPrevious).Row
          .Range("A2:AA" & LR1).Sort key1:=.Range("AA2"), order1:=xlAscending
          Set Rng = .Range("AA2:AA" & LR1)
          With Rng
             For i = LR1 To 2 Step -1
                If Not Rng(i).Value = Rng(i).Offset(-1, 0).Value Then
                   Rng(i).EntireRow.Insert
                End If
             Next i
          End With
          LR1 = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                            SearchDirection:=xlPrevious).Row
          Set Rng = .Range("A2:A" & LR1)
    
          Rng.SpecialCells(xlCellTypeBlanks).Select
          .Range("A1:AA1").Copy
          Selection.PasteSpecial
          Application.CutCopyMode = False
          With Rng
             For i = LR1 To 2 Step -1
                If Rng(i).Value = "Row ID" Then
                   Rng(i).Resize(2, 1).EntireRow.Insert
                End If
             Next i
          End With
       End With
       Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Contributor
    Join Date
    04-30-2013
    Location
    washington
    MS-Off Ver
    Excel 2019
    Posts
    168

    Re: VBA to split report according to segmentation of rows unique values to sheet check

    Wow it works sir I do have small change where split columns AA change to AC how to change code if it run on AC column

    @ every segment i need two rows down above header i need to update this "FY-16 Business Entity Report for the &" Dispute
    Attached Files Attached Files

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA to split report according to segmentation of rows unique values to sheet check

    Hi John

    you had it mostly correct except this line of Code...
    If Rng(i).Value = "Source" Then
    should be...
    If Rng(i).Value = "Row ID" Then
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    04-30-2013
    Location
    washington
    MS-Off Ver
    Excel 2019
    Posts
    168

    Re: VBA to split report according to segmentation of rows unique values to sheet check

    Amazing Piece of code!! Solved by jaslake greatful to you sir

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA to split report according to segmentation of rows unique values to sheet check

    You're welcome...glad I could help.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA to split unique values from 2 sheet end with formula
    By johnlara in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-15-2016, 11:03 AM
  2. Need vba to split unique rows of column H,G,I from sheet of East,West,North
    By johnmacpro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2016, 09:24 AM
  3. Split Data Unique Value From 2 Sheet of A column and Move to 2 Sheet with Splited Values
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-21-2013, 04:21 AM
  4. Replies: 1
    Last Post: 04-11-2013, 01:02 PM
  5. Replies: 2
    Last Post: 02-13-2013, 03:14 PM
  6. Split Rows For Unique Values In A Column To Different Workbooks
    By ashishmac in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-22-2013, 02:45 PM
  7. Copy rows with unique values to another sheet
    By vmed in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2006, 03:20 PM

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