+ Reply to Thread
Results 1 to 13 of 13

Common Spacing of Rows

  1. #1
    rajeev
    Guest

    Common Spacing of Rows

    Hi,
    I have a data that runs to about 7500 rows containing different
    components.I want to create a common space say 5 rows after every
    change of components.Right now i am doing it manually & it takes a hell
    of a time to complete it.Anyone can help me to solve this problem.
    Thanks in advance.

    Regards
    Rajeev


  2. #2
    Don Guillett
    Guest

    Re: Common Spacing of Rows

    try this assuming column A

    Sub insertrows()
    For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
    If Cells(i - 1, 1) <> Cells(i, 1) Then _
    Rows(i).Resize(5, 1).EntireRow.Insert
    Next i
    End Sub


    --
    Don Guillett
    SalesAid Software
    [email protected]
    "rajeev" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    > I have a data that runs to about 7500 rows containing different
    > components.I want to create a common space say 5 rows after every
    > change of components.Right now i am doing it manually & it takes a hell
    > of a time to complete it.Anyone can help me to solve this problem.
    > Thanks in advance.
    >
    > Regards
    > Rajeev
    >




  3. #3
    Gord Dibben
    Guest

    Re: Common Spacing of Rows

    Rajeev

    This macro will insert 5 blank rows after each change of component in column A

    Sub InsertRow_At_Change()
    Dim i As Long
    With Application
    .Calculation = xlManual
    .ScreenUpdating = False
    End With
    For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
    If Cells(i - 1, 1) <> Cells(i, 1) Then _
    Cells(i, 1).Resize(5, 1).EntireRow.Insert
    Next i
    With Application
    .Calculation = xlAutomatic
    .ScreenUpdating = True
    End With
    End Sub


    Gord Dibben Excel MVP

    On 8 May 2005 06:04:29 -0700, "rajeev" <[email protected]> wrote:

    >Hi,
    >I have a data that runs to about 7500 rows containing different
    >components.I want to create a common space say 5 rows after every
    >change of components.Right now i am doing it manually & it takes a hell
    >of a time to complete it.Anyone can help me to solve this problem.
    >Thanks in advance.
    >
    >Regards
    >Rajeev



  4. #4
    rajeev
    Guest

    Re: Common Spacing of Rows

    Don,
    Very difficult to understand.Will you please clarify it in simple way.

    Regards
    Rajeev


  5. #5
    rajeev
    Guest

    Re: Common Spacing of Rows

    Dear Gord,
    Truely speaking it is very difficult to understand.I am an accountant &
    does not have any software skills.Will you please explain it in a
    simple way.

    Regards
    Rajeev


  6. #6
    Gord Dibben
    Guest

    Re: Common Spacing of Rows

    Rajeev

    If not familiar with VBA and macros, see David McRitchie's site for more on
    "getting started".

    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    In the meantime..........

    First...create a backup copy of your original workbook.

    To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

    Hit CRTL + R to open Project Explorer.

    Find your workbook/project and select it.

    Right-click and Insert>Module. Paste the code in there. Save the
    workbook and hit ALT + Q to return to your workbook.

    Run the macro by going to Tool>Macro>Macros.

    You can also assign this macro to a button or a shortcut key combo.


    Gord Dibben Excel MVP

    On 9 May 2005 01:55:21 -0700, "rajeev" <[email protected]> wrote:

    >Dear Gord,
    >Truely speaking it is very difficult to understand.I am an accountant &
    >does not have any software skills.Will you please explain it in a
    >simple way.
    >
    >Regards
    >Rajeev



  7. #7
    rajeev
    Guest

    Re: Common Spacing of Rows

    Thanks lot Gord at last i have got it but i am
    facing a new problem.The macro creates a gap of 5 rows between every
    part no.However i want to create a gap only when the part no.
    changes.Suppose if 3 rows are occupied by same part no. then i want
    that macro should run only after that part no. changes.
    However once again thanks lot for solving substantial portion of my
    problem.

    Rajeev


  8. #8
    Registered User
    Join Date
    05-10-2005
    Posts
    16
    hi Gord, nice one. saves me tons of time.

    which field (in your VB code) should i modify if i want the macro to work based on other columns?

    for example Column A (country) is all Japan,
    column B (cities) i have Tokyo, Osaka.. etc and when the row changes (Toyko to osaka or other cities) then the macro add 5 rows to it..

    one way i can think of (without modifying your VB code) is to shift my columns then run the macro, after that shift columns back.

    2nd question, how should i add to the code to make it add 5 rows AND THEN copy the row on top?


    thanks,

  9. #9
    Don Guillett
    Guest

    Re: Common Spacing of Rows

    Gord's macro will work, as written, if your part numbers are in col A. If
    not, modify to suit.

    --
    Don Guillett
    SalesAid Software
    [email protected]
    "rajeev" <[email protected]> wrote in message
    news:[email protected]...
    > Thanks lot Gord at last i have got it but i am
    > facing a new problem.The macro creates a gap of 5 rows between every
    > part no.However i want to create a gap only when the part no.
    > changes.Suppose if 3 rows are occupied by same part no. then i want
    > that macro should run only after that part no. changes.
    > However once again thanks lot for solving substantial portion of my
    > problem.
    >
    > Rajeev
    >




  10. #10
    Registered User
    Join Date
    05-10-2005
    Posts
    16
    hmm.. cant see which to modify.. do i change the "i"?

    keep on trying..

  11. #11
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545

    Talking to yourself....

    Foxxkat: your posts are NOT being seen by Gord (or anyone outside of this forum for that matter). That function in this forum is not working. Posts entered here are not sent up to the newsgroups.

    Sorry.
    Bruce
    The older I get, the better I used to be.
    USA

  12. #12
    Gord Dibben
    Guest

    Re: Common Spacing of Rows

    Rajeev

    As written and posted, the macro will insert 5 rows at each change in part
    number if the numbers are contiguous in column A.

    If it is inserting 5 rows between every part number then your part numbers are
    not the same or not contiguous or not in Column A.

    In column A

    1
    1
    1
    2
    2
    2
    3
    3
    3

    The macro will insert 5 rows after A3 and A6


    Gord


    On 10 May 2005 00:31:16 -0700, "rajeev" <[email protected]> wrote:

    >Thanks lot Gord at last i have got it but i am
    >facing a new problem.The macro creates a gap of 5 rows between every
    >part no.However i want to create a gap only when the part no.
    >changes.Suppose if 3 rows are occupied by same part no. then i want
    >that macro should run only after that part no. changes.
    >However once again thanks lot for solving substantial portion of my
    >problem.
    >
    >Rajeev



  13. #13
    rajeev
    Guest

    Re: Common Spacing of Rows

    Thanks Gord i now got it.
    Ealiar it takes me at least 10hrs to get the work completed.Now few
    seconds.


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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