Msgbox to give the number of new rows copied or count and give the new entries in one code execution.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
I have to this code that copy and paste for eg: after filtering.
So i want to ask if there is way to count number of new rows copied and pasted:)

I sure this will be easy for you guys!

Thanks Pedie

Code:
Sub Macro2()
Sheet1.Range("A1:B1").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$B$24").AutoFilter Field:=2, Criteria1:="N"
    Range("A3").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Range("D3").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Selection.AutoFilter
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Try:
Code:
Sub Macro2()
Dim i as Long
Dim RangeAcross as Range
    Sheet1.Range("A1:B1").AutoFilter
    ActiveSheet.Range("$A$1:$B$24").AutoFilter Field:=2, Criteria1:="N"
    set RangeAcross = Range(Range("A3"), Range("A3").End(xlToRight))
    i = Range("A3").End(xlDown).Row
    Range(RangeAcross, Range("A" & i)).Copy
    Range("D3").PasteSpecial Paste:=xlPasteValues
    Selection.AutoFilter
    MsgBox i & " Rows have been copied and pasted"
End Sub
 
Upvote 0
Hi Jack, when i run this code it is count the whole table row instead of special row (row that were filetered to be copied)...it is giving result as 22 but the rows copied were only 7 rows when filtered with "N"..

Could you pls check it again???
 
Upvote 0
I think i found it: thanks anyways. Will get back latter... :) But if anyone has anything to share then please do.
I used to count before being copied....
Code:
intCount = WorksheetFunction.Subtotal(3, Range("A2:A10000"))
 
Upvote 0
Perhaps

Rich (BB code):
    Application.CutCopyMode = False
    MsgBox Range("A1:A24").SpecialCells(xlCellTypeVisible).Count & "rows copied", vbInformation
    Selection.AutoFilter
 
Upvote 0

Forum statistics

Threads
1,215,746
Messages
6,126,639
Members
449,325
Latest member
Hardey6ix

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