ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro to copy value in empty cells (https://www.excelbanter.com/excel-discussion-misc-queries/22628-macro-copy-value-empty-cells.html)

Esrei

Macro to copy value in empty cells
 
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.

Bernie Deitrick

Esrei,

Post your old code.

HTH,
Bernie
MS Excel MVP


"Esrei" wrote in message
...
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.




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
"Bernie Deitrick" wrote:

Esrei,

Post your old code.

HTH,
Bernie
MS Excel MVP


"Esrei" wrote in message
...
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.





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


"Esrei" wrote in message
...
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
"Bernie Deitrick" wrote:

Esrei,

Post your old code.

HTH,
Bernie
MS Excel MVP


"Esrei" wrote in message
...
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.








All times are GMT +1. The time now is 12:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com