+ Reply to Thread
Results 1 to 10 of 10

Insert rows based on the value on column F

  1. #1
    Registered User
    Join Date
    10-31-2009
    Location
    Madurai, India
    MS-Off Ver
    Excel 2003
    Posts
    6

    Talking Insert rows based on the value on column F

    Hi All

    I want to insert rows based on the coloumn F (has 6.00 on it)

    2061 01.08.2009 01.08.2009 6.00

    Since the coloumn F has value 6 on it, i want to insert 5 rows below the current row

    Could you please help me doing it?

    Million Thanks
    sramchan
    Last edited by sramchan; 10-31-2009 at 06:51 AM.

  2. #2
    Registered User
    Join Date
    10-31-2009
    Location
    CF
    MS-Off Ver
    Excel 2003
    Posts
    1

    Thumbs up Re: Insert rows based on the value on column F

    Macros, Macros Macros.... :D

    Dim MyLine As Integer
    Sub AddRow_ColumnF(Line As Integer, Q As Integer)
    Rows(Line + 1 & ":" & Line + Q).Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    End Sub

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 6 Then
    Call AddRow_ColumnF(MyLine, Range("F" & MyLine).Value)
    End If
    End Sub

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    MyLine = ActiveCell.Row
    End Sub


    Ps: Put in the sheet you using.

    This is it!!!!
    Renato Lacerda

  3. #3
    Registered User
    Join Date
    10-31-2009
    Location
    Madurai, India
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Insert rows based on the value on column F

    Thanks for replying renatolacerda

    Sorry for being dumb

    Could you please explain how do i create the macro

    I go to tools --> Macro --> "InsertRow"

    It then opens up a visual basic editor

    do i put your code inside it?

  4. #4
    Registered User
    Join Date
    10-31-2009
    Location
    Madurai, India
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Insert rows based on the value on column F

    can someone help?

  5. #5
    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: Insert rows based on the value on column F

    Hi sramchan
    The code given you (not wrapped in code tags) is not complete. If you are willing to show me what you have and what you wish it to look like (before and after), perhaps I can help.
    John
    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.

  6. #6
    Registered User
    Join Date
    10-31-2009
    Location
    Madurai, India
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Insert rows based on the value on column F

    this is how my file looks like
    857 2050 Standby X 01.08.2009 01.08.2009 2.00
    975 2050 Standby X 01.08.2009 01.08.2009 2.00
    611 2050 Standby X 01.08.2009 01.08.2009 2.00
    277 2050 Standby X 01.08.2009 01.08.2009 2.00
    934 2050 Standby X 01.08.2009 01.08.2009 3.00
    If i have number 2 on the last coloumn, i want one more row and the dates need to be incremented by 1.

    857 2050 Standby X 01.08.2009 01.08.2009 1.00
    857 2050 Standby X 02.08.2009 02.08.2009 1.00
    975 2050 Standby X 01.08.2009 01.08.2009 1.00
    975 2050 Standby X 02.08.2009 02.08.2009 1.00
    611 2050 Standby X 01.08.2009 01.08.2009 1.00
    611 2050 Standby X 02.08.2009 02.08.2009 1.00
    277 2050 Standby X 01.08.2009 01.08.2009 1.00
    277 2050 Standby X 02.08.2009 02.08.2009 1.00
    934 2050 Standby X 01.08.2009 01.08.2009 1.00
    934 2050 Standby X 02.08.2009 02.08.2009 1.00
    934 2050 Standby X 03.08.2009 03.08.2009 1.00
    thanks for the help
    Last edited by sramchan; 11-02-2009 at 09:32 AM.

  7. #7
    Registered User
    Join Date
    10-31-2009
    Location
    Madurai, India
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Insert rows based on the value on column F

    is there any other information that is needed

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Insert rows based on the value on column F

    Yes; post a workbook.
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Registered User
    Join Date
    10-31-2009
    Location
    Madurai, India
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Insert rows based on the value on column F

    Please find the data i have right now. (sample_input)
    and the output expected from it (sample_output)
    Attached Files Attached Files

  10. #10
    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: Insert rows based on the value on column F

    Hi sramchan
    The attached workbook has procedures that appears to accomplish what you're trying to do except that I can't seem to get the leading 0's on the date fields. Sheet1 is your original input, Sheet3 is your original output. All the activity of the procedures take place on Sheet2.
    See if it works for you and let me know of any issues. John
    Attached Files Attached Files

+ 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