Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 17th, 2006, 08:11 AM
Authorized User
 
Join Date: Apr 2006
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default copy paste problem

Hi,

I have a worksheet called "data" with 7 groups consisting of 3 records per group (ranked from 1 thrue 3). the 3 records are shown by means of the filter (<=3). FYI Total number of records are around 500.

Each week I do a download which will bring differences in the data, for example record 1 in group 1 (which is filtered) is infact record 300 from the dataset and next week it is record 350. My problem is: the filtered dataset is always 21 (7 groups x 3 ranks) and want to copy and paste them in another worksheet. The problem is when I do a new download, the references in the pastelink is based on the previous week hence data error. sometimes a group of 2 records and the second group holds 4 records.

Is there a way in VB for example to select only the data 21 records and paste them in another location. I tried to use CTRL-A but in the code it states a cell number which is then hardcoded (what I dont want)next week dataset can be larger or smaller (500 records).




 
Old November 20th, 2006, 07:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Paul,

You want to use the SpecialCells method of the range objcet. Example as follows:

Code:
Range("A1:G500").SpecialCells(xlCellTypeVisible).Select
The SpecialCells method replicates the functionality of the GoTo -> Special... box and is very useful for quick filtering to certain types of things (i.e. cells with comments in them, visible cells, etc.)

HTH,
Maccas

 
Old November 20th, 2006, 07:48 AM
Authorized User
 
Join Date: Apr 2006
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Maccas,

Wouldnt give this a problem because G500 is a static value in the code, the list what im talking about is shrinking and growing depending of the amount of data per week, I was looking for a dynamic solution.

rgrds,

Paul.

 
Old November 20th, 2006, 07:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Well then use:

Code:
ThisWorkbook.Sheets("Sheet1").UsedRange.SpecialCells(xlCellTypeVisible).Select
 
Old November 20th, 2006, 10:48 AM
Authorized User
 
Join Date: Apr 2006
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Great stuff!!! how do you know when to use for example (xlCellTypevisible) ? it does the job.

Thanks again!!!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable Copy Paste sridevi HTML Code Clinic 5 August 11th, 2007 05:09 AM
copy paste !!!!!!! dpkbahuguna Beginning VB 6 1 March 30th, 2007 10:06 AM
Copy, Paste dpkbahuguna Beginning VB 6 1 October 26th, 2006 10:30 AM
copy and paste url k.manisha ASP.NET 1.0 and 1.1 Professional 1 October 14th, 2006 05:15 AM
Copy and append paste canmex Access 2 October 7th, 2003 01:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.