Results 1 to 5 of 5

Thread: VBA to Create Grouping (Difficult)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    So how does one know which row to show and which to hide? In other words, what is the logical flow to create the groups?
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  2. #2
    Junior Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0
    Hi

    I have tried creating macros but they are not working properly as it does not give results as per After Worksheet tab.

    Code:
    Sub Blanks()
      
    'Remove Bolds on Blank Cells
        Cells.Select
        Selection.SpecialCells(xlCellTypeBlanks).Font.Bold = False
     
    End Sub
    
    Sub Check()
    '
    ' 
    '
    Dim RowCount As Integer
    Dim RowNo As Integer
    Dim iColNo As Long
    Dim LastCheck As Integer
    Dim FirstCheck As Integer
    Dim CalcFlag As Boolean
    
    'Count number of rows
    RowCount = ActiveSheet.UsedRange.Rows.Count
    
    'Initialise the range
    LastCheck = 4
    
    
    
    For iColNo = 3 To 9
    For RowNo = 2 To RowCount
    
    If Cells(RowNo, iColNo).Font.Bold = True Then
         FirstCheck = RowNo - 1
    End If
    
    If FirstCheck > LastCheck Then
    Rows(FirstCheck & ":" & LastCheck).group
    'MsgBox (FirstCheck & "and" & LastCheck)
    Cells(RowNo, iColNo).Font.Underline = True
    'Selection.Rows.Group
    LastCheck = FirstCheck + 2
    End If
    Next RowNo
    LastCheck = LastCheck + 1
    Next iColNo
    
    
    End Sub
    Structure
    Grouping Starts one cell below the bold and grouping ends before next bold. For instance, Col I relates to Staff Permanent grouping which
    starts from row 10 and finishes on row 28.

    Looping structure would loop through I to D.


    End goal is to have structure below at Level 1 grouping.

    1000 Group Accounts
    41 Profit and Loss
    39 Net Surplus / (Deficit) After Tax
    42 Net Operating Surplus / (Deficit)
    43 Net Non-Operating Surplus / (Deficit)
    6 Liabilities & Equity
    28 Liabilities
    29 Ratepayers equity
    7 Asset
    8 Assets
    9 Non-Current Assets
    10 Current Assets


    From the above there grouping for Profit and Loss, Liabilities & Equity, Asset

    Hope above helps.

    Biz
    Last edited by Biz; 07-12-2011 at 03:28 AM.

Similar Threads

  1. Excel VBA Code to Add New Sheets
    By cdurfey in forum Excel Help
    Replies: 1
    Last Post: 06-25-2013, 08:05 AM
  2. VBA To Create A New Workbook
    By cdurfey in forum Excel Help
    Replies: 9
    Last Post: 05-23-2013, 06:41 PM
  3. VBA Code to create Pivot tables
    By Howardc in forum Excel Help
    Replies: 2
    Last Post: 08-05-2012, 02:41 AM
  4. Create Random Number Generator VBA
    By Admin in forum Excel and VBA Tips and Tricks
    Replies: 1
    Last Post: 12-01-2011, 10:51 AM
  5. Write/Create Text File VBA
    By Admin in forum Download Center
    Replies: 0
    Last Post: 06-20-2011, 01:39 AM

Posting Permissions

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