Solved

Could I programatically add columns in excell?

Posted on 2011-09-06
5
250 Views
Last Modified: 2012-05-12
Is there  a way to programatically copy and paste calculated columns from an existing worksheet to a newly created worksheet?  I currently do it manually, but would like to be able to just click a button and create the columns to the new worksheet that I receive from a SQL report server..  

Code examples would be helpful.    

thanks
0
Comment
Question by:epicazo
[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
  • 2
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
hitsdoshi1 earned 250 total points
ID: 36489778
Something like this would do the job.
Sub CopyCol()
    Columns("C:C").Select
    Selection.Copy
    Workbooks.Add
    Columns("C:C").Select
    ActiveSheet.Paste
End Sub

Open in new window

0
 
LVL 12

Expert Comment

by:sdwalker
ID: 36490846
If you're trying to paste the values (and not the formulas), you'll need to to replace the Activesheet.Paste with this.
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
		:=False, Transpose:=False

Open in new window

0
 

Author Comment

by:epicazo
ID: 36588894
I am sorry,   i meant from copy to another newly created excel sheet which is not the same filename
0
 
LVL 9

Expert Comment

by:hitsdoshi1
ID: 36589307
The code I mentioned earlier would copy to another newly created excel sheet only.

Line workbooks.add - creates new excel workbook
0
 

Author Closing Comment

by:epicazo
ID: 36944448
thanks.  sry for the delay
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

738 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