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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

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