LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Copying Data into another worksheet using macro

Hi all,

I am using the code generously supplied by Tom O below,
but have found that if a filter returns no result, i.e. if
the data doesn't exist in the list, it then proceeds to
paste the entire table into the destination worksheet.

What I need to happen is if no result is returns, then
nothing gets pasted (or a blank row gets pasted).

Any ideas?

Thanks in advance

Andy ;-)

Dim rng as Range
Sheets("Raw Data").Activate
If ActiveSheet.AutofilterMode then
Activesheet.AutofilterMode = False
With Range("A2")
.AutoFilter Field:=2, Criteria1:="PB to Cust*"
End with
With Activesheet.Autofilter.Range
set rng = .offset(1,0).Resize(.rows.count-1)
End With
rng.copy Destination:=Sheets("CustbyRDC").Range("A7").

if your table actually starts in A1 with a header row,
change A2 above to
A1.

--
Regards,
Tom Ogilvy

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying rows of data into new worksheet but placing data into colu Thalarctos Excel Discussion (Misc queries) 0 June 6th 10 04:01 AM
Copying worksheet with macro Janelle S[_2_] Excel Discussion (Misc queries) 2 November 2nd 08 10:38 PM
Copying Data from One Worksheet to Another Jeremy Excel Discussion (Misc queries) 2 April 21st 08 01:32 PM
Macro for Copying Worksheet to New Workbook MGC Excel Discussion (Misc queries) 10 August 17th 07 01:57 AM
Copying Row Data to Specific Worksheet [email protected] Links and Linking in Excel 1 December 20th 06 07:04 AM


All times are GMT +1. The time now is 06:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"