Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
Ram Ram is offline
external usenet poster
 
Posts: 138
Default new worksheet

I have a excel worksheet with bunch of columns.
Now I want to create a new excel sheet with only selected columns.
And user will be prompted to input the columns may be with a inputbox only
for onetime.
Example:
Let us say abc.xls has A to H columns.
User will input A C E
New excel sheet will have A, C and E columns only from abc.xls.

  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 5,441
Default new worksheet

Ram,

Try the sub below.

HTH,
Bernie
MS Excel MVP

Sub PickColumnsToCopy()
Dim mySel As String
Dim myCols As Variant
Dim i As Integer
Dim myR As Range

mySel = InputBox("Which columns to use? " & Chr(10) & _
"(Use a space to separate letters!)")

On Error GoTo ErrHandler
myCols = Split(mySel, " ")

Set myR = Cells(1, myCols(LBound(myCols))).EntireColumn
For i = LBound(myCols) + 1 To UBound(myCols)
Set myR = Union(myR, Cells(1, myCols(i)).EntireColumn)
Next i

Sheets.Add
myR.Copy Range("A1")

Exit Sub
ErrHandler:
MsgBox "There was an error"

End Sub


"Ram" wrote in message
...
I have a excel worksheet with bunch of columns.
Now I want to create a new excel sheet with only selected columns.
And user will be prompted to input the columns may be with a inputbox only
for onetime.
Example:
Let us say abc.xls has A to H columns.
User will input A C E
New excel sheet will have A, C and E columns only from abc.xls.



  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 10,124
Default new worksheet

May be quicker and easier for user to hold ctrl key and select any cell in
the column(s) desired and fire this.

Sub copyselectedcolumns()
Selection.EntireColumn.Copy
Sheets.Add
ActiveSheet.Paste
End Sub
--
Don Guillett
SalesAid Software

"Ram" wrote in message
...
I have a excel worksheet with bunch of columns.
Now I want to create a new excel sheet with only selected columns.
And user will be prompted to input the columns may be with a inputbox only
for onetime.
Example:
Let us say abc.xls has A to H columns.
User will input A C E
New excel sheet will have A, C and E columns only from abc.xls.


  #4   Report Post  
Posted to microsoft.public.excel.newusers
Ram Ram is offline
external usenet poster
 
Posts: 138
Default new worksheet

I will try today, Thank you

"Bernie Deitrick" wrote:

Ram,

Try the sub below.

HTH,
Bernie
MS Excel MVP

Sub PickColumnsToCopy()
Dim mySel As String
Dim myCols As Variant
Dim i As Integer
Dim myR As Range

mySel = InputBox("Which columns to use? " & Chr(10) & _
"(Use a space to separate letters!)")

On Error GoTo ErrHandler
myCols = Split(mySel, " ")

Set myR = Cells(1, myCols(LBound(myCols))).EntireColumn
For i = LBound(myCols) + 1 To UBound(myCols)
Set myR = Union(myR, Cells(1, myCols(i)).EntireColumn)
Next i

Sheets.Add
myR.Copy Range("A1")

Exit Sub
ErrHandler:
MsgBox "There was an error"

End Sub


"Ram" wrote in message
...
I have a excel worksheet with bunch of columns.
Now I want to create a new excel sheet with only selected columns.
And user will be prompted to input the columns may be with a inputbox only
for onetime.
Example:
Let us say abc.xls has A to H columns.
User will input A C E
New excel sheet will have A, C and E columns only from abc.xls.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to Insert Worksheet/Move and copy worksheet Excel 2003 lukerush Excel Worksheet Functions 2 September 7th 06 05:05 PM
plot graph from multiple worksheet as embedded chart object on every worksheet [email protected] Charts and Charting in Excel 3 August 24th 06 07:26 PM
plot graph from multiple worksheet as embedded chart object on every worksheet jeftiong New Users to Excel 0 August 23rd 06 01:50 PM
Upload multiple text files into 1 excel worksheet + put the filename as the first column in the worksheet Aster Excel Worksheet Functions 3 March 12th 06 09:58 AM
I want in one worksheet to relatively link to/reference cells in another without changing the format of the current worksheet. [email protected] Excel Discussion (Misc queries) 0 September 22nd 05 04:39 PM


All times are GMT +1. The time now is 08:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"