Solved

Exclude certain columns from being copied

Posted on 2012-03-20
1
160 Views
Last Modified: 2012-06-27
I'm using this code to copy data to a new worksheet.

Is it possible to exclude certain columns, say the 15th column?

For Each r In rngDb
   rngOut.Offset(i).Value = r.Resize(, 24).Value
   i = i + 1     
Next r

Open in new window

0
Comment
Question by:mcnuttlaw
1 Comment
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 37741791
You would have to loop through the cells rather than using resize, or perform the action in two blocks:

For Each r In rngDb
   with rngOut.Offset(i)
       .resize(, 14).Value = r.Resize(, 14).Value
       .offset(, 15).resize(, 8).value = r.offset(, 15).Resize(, 8).value
   End With
   i = i + 1     
Next r

Open in new window


Note: this assumes you leave a gap in the range you copy to; if you don't want that, then the first offset should be by 14 not 15.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question