?
Solved

Could I programatically add columns in excell?

Posted on 2011-09-06
5
Medium Priority
?
253 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 1000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
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 demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

719 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