Gaps in pasted rows

Lavalips

New Member
Joined
Aug 6, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi there,

I hope that you can help me.

I am wishing to copy and paste rows from a donor worksheet to a recipient worksheet based on one of 2 criteria being met in column H.

When the appropriate rows are copied across there are gaps in the recipient worksheet pertaining to the questions that didn't meet the criteria in column H.

e.g i want to copy rows A10, A23, A24, A98..... on the recipient worksheet the rows have been pasted over fine but there are massive blank rows inbetween them.

If someone could possibly help me in making sure the pasted rows on the recipient worksheet follow directly below each other without any gaps, that would be amazing.

here is the macro I am using.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim wsh As Worksheet
Dim rng As Range
If Not Intersect(Range("H10:H" & Rows.Count), Target) Is Nothing Then
Set wsh = Worksheets("NonComformitySchedule")
For Each rng In Intersect(Range("H10:H" & Rows.Count), Target)
Select Case rng.Value
Case "M", "R"
rng.EntireRow.Copy Destination:=wsh.Range("A" & rng.Row)
Case Else
' Do nothing
End Select
Next rng
Application.CutCopyMode = False
End If
End Sub


Thank you so much in advance

Richard
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi & welcome to MrExcel.
Try
VBA Code:
rng.EntireRow.Copy Destination:=wsh.Range("A" & Rows.Count).End(xlUp).Offset(1)
 
Upvote 0
rng.EntireRow.Copy Destination:=wsh.Range("A" & Rows.Count).End(xlUp).Offset(1)
Hi thank you so much for your response, unfortunately that didn't work, there are still gaps between pasted rows. damned annoying!
 
Upvote 0
There shouldn't be, that change should put the data on the first blank row using col A to find the last used row.
Do you get any errors?
 
Upvote 0
There shouldn't be, that change should put the data on the first blank row using col A to find the last used row.
Do you get any errors?
none, ill take a screen shot and redact as appropriate
 
Upvote 0
Capture.PNG
Capture2.PNG
 
Upvote 0
Do you have values in col A on every row?
Also do you have any merged cells?
 
Upvote 0
Ok, try
VBA Code:
rng.EntireRow.Copy Destination:=wsh.Range("H" & Rows.Count).End(xlUp).Offset(1, -7)
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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