Consulting

Results 1 to 3 of 3

Thread: Create table for each name in specific column

  1. #1

    Create table for each name in specific column

    Hello everyone
    I have data in sheets("Data") and I need to create table for each name in column C and leave two empty rows in between ..
    Also to put SUM formulas after each table

    I have attached expected output so as to make it clearer ..
    Thanks advanced for help
    Attached Files Attached Files

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Click the button at cell J1 of the Data sheet in the attached.
    Code is:
    Sub blah()
    Set SourceSht = Sheets("Data")
    Set RngToFilter = SourceSht.Range("A1").CurrentRegion
    Set NewSht = Sheets.Add(After:=Sheets(Sheets.Count))
    Set Destn = NewSht.Range("A1")
    Set dict = CreateObject("scripting.dictionary")
    For Each cll In Intersect(RngToFilter.Columns(2), RngToFilter.Columns(2).Offset(1))
      If Not cll.Value = Empty Then dict.Item(cll.Value) = cll.Value
    Next cll
    For Each ky In dict.keys
      RngToFilter.AutoFilter Field:=2, Criteria1:=ky
      RngToFilter.Copy Destn
      RowCount = Destn.CurrentRegion.Rows.Count
      Destn.Offset(RowCount, 4).Resize(, 4).FormulaR1C1 = "=SUM(R[-" & RowCount - 1 & "]C:R[-1]C)"
      Set Destn = Destn.Offset(RowCount + 3)
    Next ky
    RngToFilter.AutoFilter
    NewSht.Columns("A:I").EntireColumn.AutoFit
    End Sub
    Attached Files Attached Files
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    Thank you very much for this great and awesome solution
    Best and kind regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •