Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Unable to Insert Worksheet/Move and copy worksheet Excel 2003 | Excel Worksheet Functions | |||
plot graph from multiple worksheet as embedded chart object on every worksheet | Charts and Charting in Excel | |||
plot graph from multiple worksheet as embedded chart object on every worksheet | New Users to Excel | |||
Upload multiple text files into 1 excel worksheet + put the filename as the first column in the worksheet | Excel Worksheet Functions | |||
I want in one worksheet to relatively link to/reference cells in another without changing the format of the current worksheet. | Excel Discussion (Misc queries) |