VBA to copy and post data

Brandon10131

New Member
Joined
Jul 14, 2021
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
Hello,

I am trying to post copy and paste data rows from one sheet labelled PMs to another labelled Data Summary. I am using a column value of "Incomplete" in column G. I have done it somewhat successfully with help from this forum. I however am having a problem with data not being transferred if there is already another incomplete listed in a row below one which I update. Example being row 23 has an incomplete then row 18 needs it. The row 18 will not transfer over without me removing the 23 incomplete and going in a sequential order.

I also did a Row +5 to ensure it doesn't interfere with other info on my first sheet listed as Data Summary as I couldn't figure out how to ensure it went to a non filled row. Any help or nudge in the right direction would be appreciated greatly. Thank you!

If Not Intersect(Target, Range("G:G")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("PMs").Cells(Rows.Count, "G").End(xlUp).Row + 5

If Target.Value = "Incomplete" Then
Rows(Target.Row).Copy Destination:=Sheets("Data Summary").Rows(Lastrow)
End If
End If
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi & welcome to MrExcel.
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Not Intersect(Target, Range("G:G")) Is Nothing Then
      If LCase(Target.Value) = "incomplete" Then
         Target.EntireRow.Copy Sheets("Data Summary").Range("G" & Rows.Count).End(xlUp).Offset(1, -6)
      End If
   End If
End Sub
 
Upvote 0
Solution
Thank you that worked like a charm!

I will admit I am confused as to how you managed to tell Excel to select the PMs sheet without mentioning it in the actual code?
 
Upvote 0
With event code there is no need, as it's in the sheet code module it works on that sheet.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,217
Members
449,074
Latest member
cancansova

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