How can my vba count number of rows copied?

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi, how can my vba count number of rows copied?
i want the msgbox to show the # counts after the whole thing is copied.

Thanks
Pedie
Code:
x = 1
y = 65500
c = 12
Application.ScreenUpdating = False
With Sheets("Sheet1")
            For chk = x To y
                If .Cells(chk, c).Value = "X" Then
                   .Cells(chk, c).Value = "Y"
                   .Cells(chk, c).Offset(0, -11).Resize(, 11).Copy Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
                End If
            Next chk
End With
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Xld, the thing is that it will not give me the new copied row count because there are so many rows filled out with data...

I think there must be a way round right?;)
 
Upvote 0
Yo Pedie,

Try.

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> test()<br>x = 1<br>y = 65500<br>c = 12<br>Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br><SPAN style="color:#00007F">With</SPAN> Sheets("Sheet1")<br>  <SPAN style="color:#00007F">For</SPAN> chk = x <SPAN style="color:#00007F">To</SPAN> y<br>      <SPAN style="color:#00007F">If</SPAN> .Cells(chk, c).Value = "X" <SPAN style="color:#00007F">Then</SPAN><br>         .Cells(chk, c).Value = "Y"<br>         .Cells(chk, c).Offset(0, -11).Resize(, 11).Select<br>         .Cells(chk, c).Offset(0, -11).Resize(, 11).Copy _<br>            Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)<br>         Count = Count + 1<br>      <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>  <SPAN style="color:#00007F">Next</SPAN> chk<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>MsgBox Count<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,226,730
Messages
6,192,703
Members
453,748
Latest member
akhtarf3

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