Hi Nitin,, use this

 

 

Dim errormessagecode, copydata, msg As String

 

On Error Resume Next

Sheets(2).Activate

ActiveSheet.Range("$A$1:$S$1").AutoFilter Field:=19, Criteria1:="N/A"

ActiveSheet.Range("$A$1:$S$1").AutoFilter Field:=10, 
Criteria1:=Array("4-Resolved", "5-Closed", "6-Cancelled"), 
Operator:=xlFilterValues

 

If ActiveSheet.UsedRange.Columns(1).SpecialCells(xlCellTypeVisible).Count - 1 = 
0 Then GoTo errormessagecode Else GoTo copydata

 

errormessagecode:

msg = MsgBox("No Data for Copy")

Exit Sub

 

copydata:

Range("A1").Select

Range("A1").CurrentRegion.SpecialCells(xlCellTypeVisible).Copy

 

Sheets(3).Activate

ActiveSheet.Paste

 

From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] On 
Behalf Of Nitin Balodi
Sent: Monday, May 18, 2015 6:39 PM
To: excel-macros@googlegroups.com
Subject: RE: $$Excel-Macros$$ Re: VBA Error in copying filtered rows

 

Sorry Mandeep, I cant share the file due to confidentiality issue, but I am 
looking for a generic solution for this issue.



Regards.

 

Yours Sincerely,

Nitin Balodi

 

  _____  

Date: Mon, 18 May 2015 04:55:09 -0700
From: rockerna...@gmail.com
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ Re: VBA Error in copying filtered rows

send the attachment 



On Monday, May 18, 2015 at 5:19:18 PM UTC+5:30, Nitin Balodi wrote:

Hi Mandeep,

 

Thanks for the response, I have tried that and getting same result and I cannot 
give predefined rows range since these are filtered out during run time.




Regards.

 

Yours Sincerely,

Nitin Balodi

 

  _____  

Date: Mon, 18 May 2015 04:10:25 -0700
From: rocke...@gmail.com
To: excel-...@googlegroups.com
Subject: $$Excel-Macros$$ Re: VBA Error in copying filtered rows

Assign sheet names while defining a range to be copied. means you should use 
Sheet("Name").range("A1:A100") instead of Only Range and send me the snapshot 
of error. 

 

Regards, 

Mandeep baluja 



On Monday, May 18, 2015 at 4:31:22 PM UTC+5:30, Nitin Balodi wrote:

Hi Champs,

 

I am getting error in copying filetered cells. Below is the code snippet. Point 
to note is this works well when I test this code by running step-by-step (i.e. 
by using F8 key) but when run as a complete code it gives me an error:

 

 

Sheets(2).Activate

ActiveSheet.Range("$A$1:$S$1").AutoFilter Field:=19, Criteria1:="N/A"

ActiveSheet.Range("$A$1:$S$1").AutoFilter Field:=10, 
Criteria1:=Array("4-Resolved", "5-Closed", "6-Cancelled"), 
Operator:=xlFilterValues

If ActiveSheet.UsedRange.Columns(1).SpecialCells(xlCellTypeVisible).Count - 1 = 
0 Then GoTo ErrorMessageCode

 

Range("A1").Select

Range("A1").CurrentRegion.SpecialCells(xlCellTypeVisible).Copy

 

Sheets(3).Activate

ActiveSheet.Paste


Can you help me on this.

 

Thanks and Regards.

 

Yours Sincerely,

Nitin Balodi


-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel
 
FORUM RULES
 
1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.
 
NOTE : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros...@googlegroups.com.
To post to this group, send email to excel-...@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.


-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel
 
FORUM RULES
 
1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.
 
NOTE : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel
 
FORUM RULES
 
1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.
 
NOTE : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to