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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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,223,893
Messages
6,175,240
Members
452,621
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