Results 1 to 6 of 6

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

Threaded 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. #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.

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