Macro to copy value in empty cells

E

Esrei

I have a macro that insert a line every time the value in C changes. Now I
want to add that it must put in the new row in A the text that is in C in
the row just under this row.
So This would be like a heading.
Hope I am not too fuzzy.
 
E

Esrei

Bit of a long one working on a priclist to be coppied and made presentable
from a DB.

Sheets("Prys berekening").Select
Range("A1:N1").Copy
Sheets("Cust price list").Select
Range("A16").PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Sheets("Prys berekening").Select
Range("A2:N311").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Cust price list").Select
Range("A17").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("B:B,D:E,G:G,N:N").Delete Shift:=xlToLeft
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
For row_index = lastrow - 1 To 2 Step -1
If Cells(row_index, "D").Value <> _
Cells(row_index + 1, "D").Value Then
Cells(row_index + 1, "D").EntireRow.Insert _
(xlShiftDown)
End If
Next
End Sub
 
B

Bernie Deitrick

Esrei,

Change

For row_index = lastrow - 1 To 2 Step -1
If Cells(row_index, "D").Value <> _
Cells(row_index + 1, "D").Value Then
Cells(row_index + 1, "D").EntireRow.Insert _
(xlShiftDown)
End If

To:

For row_index = lastrow - 1 To 2 Step -1
If Cells(row_index, "D").Value <> _
Cells(row_index + 1, "D").Value Then
Cells(row_index + 1, "D").EntireRow.Insert _
(xlShiftDown)
Cells(row_index+1,1).Value = Cells(row_index +2,3).Value
End If

HTH,
Bernie
MS Excel MVP
 
Top