Solved

Exclude certain columns from being copied

Posted on 2012-03-20
1
163 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

734 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