p = p + 1 is not working?

Darkcloud617

New Member
Joined
Sep 7, 2017
Messages
38
Hopefully a quick questions. The code below works like I need it to, however, it does not seem to copy the row to the other sheet. In fact... excel seems to not do anything about the p = p + 1. I am sure its an easy mistake made but I cannot seem to find the problem. Any ideas on why that may not be happening? Very much appreciated.


Code:
Sub Pending(): Dim wp As Worksheet, wa As Worksheet, a As Long, p As String
Set wp = Sheets("Pending"): Set wa = Sheets("Projects"):
p = Application.Max(3, wp.Range("A" & Rows.Count).End(xlUp).Row + 1)
For a = 5 To wa.UsedRange.Rows.Count


If wa.Range("Q" & a) = "Move" Then
wa.Range("A" & a).Resize(1, 19).Value = wa.Range("A" & p).Resize(1, 19).Value
wp.Range("A" & p) = "": p = p + 1:


End If
Next a
End Sub
 
It didn't, the problem was that you were copying from wp to wa, rather than the other way round
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,829
Messages
6,181,219
Members
453,024
Latest member
Wingit77

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