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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
66,064
Office Version
  1. 365
Platform
  1. Windows
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
 
Solution

Brandon10131

New Member
Joined
Jul 14, 2021
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
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?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
66,064
Office Version
  1. 365
Platform
  1. Windows
With event code there is no need, as it's in the sheet code module it works on that sheet.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
66,064
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Forum statistics

Threads
1,148,370
Messages
5,746,303
Members
424,006
Latest member
Metal_warrior

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
Top