+ Reply to Thread
Results 1 to 6 of 6

select entire column based on cell value

Hybrid View

  1. #1
    Registered User
    Join Date
    09-22-2011
    Location
    Buffalo
    MS-Off Ver
    Excel 2010
    Posts
    11

    select entire column based on cell value

    Hi, in my macro, I'm trying to have the macro select an entire column (ie W) based on the cell value my users will input ( ie W). Here is my code with the column value hard coded.

    ' Macro2 Macro
    ''
    Columns("W:W").Select
    Selection.Copy

    Any suggestions would be greatly appreciated. Jim
    Last edited by jcfrancisco; 10-04-2011 at 09:47 AM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: select entire column based on cell value

    Oh this is very simple. All you need to do is as follows:

    Dim UserReply As String
    
    Sub test()
        UserReply = InputBox("Please enter column alphabet", "Column Alphabet")
    
        Columns(UserReply & ":" & UserReply).Select
        Selection.Copy
    
    End Sub

  3. #3
    Registered User
    Join Date
    09-22-2011
    Location
    Buffalo
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: select entire column based on cell value

    thank you. This works great!!!

  4. #4
    Registered User
    Join Date
    09-22-2011
    Location
    Buffalo
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: select entire column based on cell value

    if I could ask 1 more favor. This works great in my one active worksheet, can I make it do the same thing on all worksheets in my workbook? There's like 20.

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: select entire column based on cell value

    Is the column the same in all worksheets? If not, is it fine with you if the user receives 20 input boxes asking for the alphabet?

  6. #6
    Registered User
    Join Date
    09-22-2011
    Location
    Buffalo
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: select entire column based on cell value

    yes the collumn is the same in all worksheets. Now that I think of it, maybe I shld just have the user input the the collumn letter in a "set up" sheet and have the macro take it from there.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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