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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,274
Messages
6,123,993
Members
449,137
Latest member
abdahsankhan

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