Solved

Could I programatically add columns in excell?

Posted on 2011-09-06
5
251 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 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.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

626 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