Results 1 to 1 of 1

Adding to existing macro, update value in inserted rows

Threaded View

  1. #1
    Registered User
    Join Date
    01-18-2013
    Location
    Birmingham
    MS-Off Ver
    Excel 2007
    Posts
    5

    Adding to existing macro, update value in inserted rows

    Please help I have a macro in my worksheet that looks at column K2:K1000 and based on the value in that cell it copies the entire row and inserts that many rows minus 1 and pastes the data into those new rows that part works like a charm. What I need help with is column J2:J1000 I want to be able to add text to the end of cells in column J if the value is 3 for example when the macro is finished running I will have 3 rows and column J will have 3 cells that show Z2:WM:MASTER_DATA now if the value in K2:K1000 equals 3 then I want the cells to change to Z2:WM:MASTER_DATA:Mad , Z2:WM:MASTER_DATA:STL and Z2:WM:MASTER_FLD. I will also have a value of 2 & 5 in column K2:K1000 and I will want to do the same thing to them. I hope I have explained my situation ok. Any help would be greatly appreciated!! Below is my code for the copying of new rows and data along with an attachment of my worksheet everything is on sheet2. Thanks you!


    Sub InsertRow_By_K_Value()
    'Determine last Row with data in Column K
      lastRw = Cells(Rows.Count, "K").End(xlDown).Row
    'Loop through rows in reverse order
        For rw = lastRw To 2 Step -2
    'If Column K > 0, insert Rows and copy data
         If Cells(rw, "K") > 0 Then
                For newRw = 1 To Cells(rw, "K") - 1
    'Insert/Copy rows
             Cells(rw, "K").EntireRow.Copy
             Cells(rw, "K").EntireRow.Insert shift:=xlDown
           Next
         End If
        Next
    
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro For Inserting Rows, After Every Nth Row and adding text to the inserted row
    By xxBEANCOUNTERxx in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2014, 07:47 PM
  2. [SOLVED] Adding an auto delete rows to yours already existing macro for emailing
    By msgtrainey in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-19-2012, 06:20 AM
  3. Replies: 2
    Last Post: 05-30-2006, 01:55 PM
  4. Formula doesn't update when rows are inserted
    By arreferee in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-12-2006, 11:55 AM
  5. Replies: 2
    Last Post: 09-20-2005, 05:05 PM

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