Help with formula

  • Thread starter Thread starter Stanley Braverman
  • Start date Start date
S

Stanley Braverman

This code was submitted by SeanC. What this code does is copy the contents
of row A and inserts a row above cells that contains data AND copies
complete row to inserted row and deletes data from original row.
This code counts from last row to first and thats ok.
However this is what I need.
Example of what I need:
Column A B C D
time for A Break original row

New inserted row:
Column A B C D
time inserted row
for A Break original row

Public Sub Temp()
Dim lngRowCount As Long
For lngRowCount = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
If Not IsEmpty(Cells(lngRowCount, 1)) Then
Rows(lngRowCount + 1).EntireRow.Insert shift:=xlDown
End If
Next
End Sub

How can I modify this code


Thanks
 
Try

Public Sub Temp()
Dim lngRowCount As Long
For lngRowCount = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
If Not IsEmpty(Cells(lngRowCount, 1)) Then
Rows(lngRowCount).EntireRow.Insert Shift:=xlDown
Cells(lngRowCount + 1, 1).Cut
Cells(lngRowCount, 1).Select
ActiveSheet.Paste
End If
Next
End Sub

Hope this helps,

Hutch
 
Try

Public Sub Temp()
Dim lngRowCount As Long
For lngRowCount = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
If Not IsEmpty(Cells(lngRowCount, 1)) Then
Rows(lngRowCount).EntireRow.Insert Shift:=xlDown
Cells(lngRowCount + 1, 1).Cut
Cells(lngRowCount, 1).Select
ActiveSheet.Paste
End If
Next
End Sub

Hope this helps,

Hutch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top