+ Reply to Thread
Results 1 to 6 of 6

Selecting column of the active cell

  1. #1
    Registered User
    Join Date
    10-20-2005
    Location
    Ithaca, NY, USA
    MS-Off Ver
    2004 for Mac
    Posts
    63

    Selecting column of the active cell

    I've got a macro that I want to run only on a single column, but that column might be different on different worksheets. I've got the code to select the cell that contains the correct data (and actually make it the active cell), but I can't seem to move from that to selecting the entire column it is in, so that my Cells.Replace commands only run on that selection.

    Can anyone help?

    Thanks, and once again my apologies for being so basic. If the boss would just *pay* for a pro, we wouldn't have these difficulties. . . .

    ctap

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-20-2005
    Location
    Ithaca, NY, USA
    MS-Off Ver
    2004 for Mac
    Posts
    63

    Thank you!

    Thank you ever so much!

    Now all I have to do is trap the error if it can't find the column, and I'm done!

    ctap

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    It sounds like you are using a similar technique as this code. Note how to detect when X is not present.
    Please Login or Register  to view this content.
    I'm also guessing that you are Selecting more than is nessesary. That can slow you down tremendously and also will get you in trouble if you run a macro with the wrong sheet active.

  5. #5
    Registered User
    Join Date
    10-20-2005
    Location
    Ithaca, NY, USA
    MS-Off Ver
    2004 for Mac
    Posts
    63

    You're probably right

    Unfortunately, I need to run the bulk of the code only when x is found, and otherwise I need my sheet counter to advance one and go on to the next worksheet in the workbook. I *did* have it running only on my selected column, but for some reason when I try to trap the error, I lost that again. It's very annoying.

    I don't know enough to know how to avoid searching the whole column: there may be two rows (the first being a header row) or there may be 150 rows. There's just no way to know. While I am certain there is code to meet this contingency, right now I'm just trying to get the thing to run, regardless of what the worksheets in the workbook are. I'll worry about efficiency after that.

    Your trap seems to work: it did complete the test workbook, with one worksheet deliberately put in there to gum up the works. Unfortunately now I have to try to figure out how I get it to respect my entire column selection again.

    Thanks so much for the next step in my path!

    ctap

  6. #6
    Registered User
    Join Date
    10-20-2005
    Location
    Ithaca, NY, USA
    MS-Off Ver
    2004 for Mac
    Posts
    63

    Why isn't the selection holding?

    If anyone has any ideas why the EntireColumn selection isn't holding with the trap in place when it did work before, I'd appreciate hearing them. I go straight from ActiveCell.EntireColumn.Select to my Selection.Replace statement, with nothing between, so I'm flummoxed.

    Thank you!

    ctap

+ 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