Consulting

Results 1 to 7 of 7

Thread: Solved: Inserting A New Row For Each Account Number In A Spreadsheet

  1. #1

    Solved: Inserting A New Row For Each Account Number In A Spreadsheet

    Morning,

    I have a spreadsheet that contains a list of account numbers in excel that I need to insert a new row below each one to seperate the accounts. The account numbers are contained in Row 'A'. Can anyone give me an exmaple piece of VBA to do this?

    Regards,

    Mattster

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Public Sub ProcessData()
    Const TEST_COLUMN As String = "A" '<<<< change to suit
    Dim Lastrow As Long
    Dim i As Long

    Application.ScreenUpdating = False

    With ActiveSheet

    Lastrow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
    For i = Lastrow to 2 Step -1

    .Rows(i + 1).Insert
    Next i
    End With

    Application.ScreenUpdating = True
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Thanks xld,

    I'd like to sum the total amount of each account (column 'C' holds financial info) in the blank rows inserted below each set of accounts.

    Can VBA do this? any pointers would be superb!!

    Regards,

    Mattster

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Post your workbook and bypass the second-guessing.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    Hi xld,

    Here is the workbook for an example.

    Regards,

    Mattster

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Just use the built-in Data>Subtotal function, it should give you just what you want.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    Thanks xld,

    Perfect.

    Regards,

    Mattster

Posting Permissions

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