Macro to insert blank row on change of value and copy cells from next row

tsherv

New Member
Joined
Dec 14, 2011
Messages
20
I'm using Excel 2010 and am trying to solve a problem. My spreadsheet contains 3 columns: Job# (column A), Process# (column B), Process Hours (column C). I want to insert a "dummy row" for each job. The dummy row will show the job#, but have static values for Process# process hours. I found a macro that goes through my data and inserts a blank row after every change of Job#. Now I need to figure out a macro that will insert the job# (copied from column A in the row below the blank row), and enter the value of 1 in Process#, and the value of 0 in the process hours column.

Here's the code I'm using to insert the blank row:

Sub InsertRows()
Dim lastRow As Long
Dim rowPtr As Long

lastRow = Range("A" & Rows.Count).End(xlUp).Row
For rowPtr = lastRow To 2 Step -1
If Not IsEmpty(Range("A" & rowPtr)) Then
If Range("A" & rowPtr) <> Range("A" & rowPtr - 1) Then
Range("A" & rowPtr).EntireRow.Insert
End If
End If
Next
End Sub

Where do I go from here? How would I copy and paste the job# in column A from the next row below, and paste it in column A of the blank row? How would I insert static values in column B & C of the blank row?

Any help would be appreciated!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top