+ Reply to Thread
Results 1 to 4 of 4

Macro to select fixed amount of cells to the right and left

  1. #1
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Macro to select fixed amount of cells to the right and left

    Hi all,
    I know this is relatively straight forward but I can't get it to work properly.

    I basically want to have a macro which selects 16 cells from the same row.

    When I select a cell in column B - i also want to select 14 cells to the right, and one cell to the left (as well as cell in column B) - I just can't get the macro right.

    The row can vary - hence why I can't specify the same cells in my macro.

    So if I click in cell B10 - I want the macro to select A10:P10.
    If i click in B48 - I want the macro to select A48:P48

    Thanks in advance

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Macro to select fixed amount of cells to the right and left

    You could use a combination of offset and resize

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Macro to select fixed amount of cells to the right and left

    That doesn't select the cells though, it just flags up a message box.

    I need to select the cells (to be copied, cut, deleted etc) based upon the row I am currently in.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Macro to select fixed amount of cells to the right and left

    I know it only displays the ranges address but you did not post any code so I could see in what context you where using it.

    If you want to select the cells then just adjust the code.

    Please Login or Register  to view this content.

+ 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