+ Reply to Thread
Results 1 to 14 of 14

Select specific columns based on column numbers

  1. #1
    Registered User
    Join Date
    08-11-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    93

    Select specific columns based on column numbers

    Hello,

    ISelect specific column.xlsx

    There are three sheets in the attached workbook.

    I have specified the column numbers in "Requirement", based on the column numbers I want macro to select specified columns from "Data" tab and pasted on the "Outcome" tab.

    An example workbook is attached here. Please let me know if this can be Programmed.

    Regards,
    Sandeep

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Select specific columns based on column numbers

    You dont need VBA for this, this formula, copied down and across will give you what you want....
    =IF(INDEX(Data!$A:$J,ROW(),INDIRECT("Requirement!a"&COLUMN()+1))=0,"",INDEX(Data!$A:$J,ROW(),INDIRECT("Requirement!a"&COLUMN()+1)))
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Select specific columns based on column numbers

    Hello sandiptemkar

    Since you did ask this question in the VBA forum, I have provided you with a VBA solution.

    The attached workbook has a button the user can click after the column numbers have been entered. This will copy the headers from the Data sheet. The first row of the Outcome sheet is cleared and the new headers copied. All ranges are dynamic.

    Here is the macro code that has been added to the workbook. It is annotated to make the code easier to understand.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    08-11-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Select specific columns based on column numbers

    Thanks Both,

    Dear Ross,

    The above code did not work for the text.

    I tried many times but could not do it for my report.

    Report is attached herewith please see if this can be fixed.

    Sandeep
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    08-11-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Select specific columns based on column numbers

    Excel Champs and Moderators,

    Please help me on the above issue; I am just one step behind from getting this fixed.

    Regards,
    Sandeep

  6. #6
    Registered User
    Join Date
    08-11-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Select specific columns based on column numbers

    Can anyone help please?

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Select specific columns based on column numbers

    Try the attached.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    08-11-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Select specific columns based on column numbers

    Thanks it worked very well!

    But still need one update if you can do so.

    While pasting the data I need macro to skip column number 4,5 and 8. No data to be pasted and these columns should be left blank.

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Select specific columns based on column numbers

    Try the attached.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    08-11-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Select specific columns based on column numbers

    Thanks Much!

    But the above code add the additional columns which I dont want since column 4,5 and 8 contains formulas and should remain untouched!

    I know its asking too much but I am just one step behind getting this fixed.

    I really appreciate all your help!

    Regards,
    Sandeep

  11. #11
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Select specific columns based on column numbers

    If you have a formula, I have to use cell refrence and this has cost-speed
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    08-11-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Select specific columns based on column numbers

    Hi,

    As of now I have given the demo sheet however in actual "Outcome" tab there would be formulas are present on column 4,5 and 8 and hence I need macro to exclude them and past the data in appropiate columns.

    Is this possible?

    If not then I would add code for adding the formulas but is too much for me because the formulaes are really very big.

    Any suggestions or ideas?

    Please let me know.

    Regards,
    Sandeep

  13. #13
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Select specific columns based on column numbers

    Sandeep,
    Did you try the attach?
    Last edited by AB33; 01-08-2014 at 08:06 AM.

  14. #14
    Registered User
    Join Date
    08-11-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Select specific columns based on column numbers

    Superb!

    It worked; issue resolved! Amazing!!!

    Thank you so much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Select Visible Cells in Specific Columns
    By RyanPJK in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-14-2013, 12:10 PM
  2. Replies: 2
    Last Post: 07-09-2012, 01:44 PM
  3. Randomly select specific numbers from array
    By carbonboywonder in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-10-2011, 09:56 AM
  4. Select specific numbers from a list based on position
    By judoist in forum Excel General
    Replies: 1
    Last Post: 11-21-2005, 12:25 PM
  5. [SOLVED] Select specific columns for a given cell selection
    By crazybass2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2005, 01:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1