+ Reply to Thread
Results 1 to 6 of 6

Selecting cells based on current cells selected?

  1. #1
    Forum Contributor
    Join Date
    02-14-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    328

    Selecting cells based on current cells selected?

    It seems I might have to use my 'ugly' workaround to delete rows in Excel 2002 (to preserve my forumulae in a column).

    In order to do this I could use some help in code that would select Col A:G.

    Here's the idea. If the cursor is on cell C28, then select cells A28:G28.
    Similarly, if the cursor is on any cell in the A:G range.
    So if the cursor is on cell B32, then select cells A32:G32.
    Or if the cursor is on cell F45, then select cells A45:G45.

    Also for multiple row selection, if the cursor is highlighting
    cells C30, C31, C32, then select cells A30:G30, A31:G31, A32:G32.

    Or if the cursor is highlighting cells C30, C31, C32, and D30, D31, D32
    then also select cells A30:G30, A31:G31, A32:G32.

    This will be the first step in my macro.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,576

    Re: Selecting cells based on current cells selected?

    Do you mean
    Please Login or Register  to view this content.
    ?

  3. #3
    Forum Contributor
    Join Date
    02-14-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    328

    Re: Selecting cells based on current cells selected?

    Quote Originally Posted by jindon View Post
    Do you mean

    ?
    Thanks jindon. It looks like it might work.
    I'm not sure where to put the code or how to test it.
    Usually I can run my code in step mode using F8 but it doesn't have any effect right now?

    Also I don't think SelectionChange will be the answer for this.
    Let me explain.

    I plan to add a button on the sheet. After selecting the appropriate cells the user will click the button and
    the subsequent selection of cells (Col a:g) will be made followed by other code (copying, pasting, deleting).

    So simply selecting cells with the mouse will not be required to start the macro.
    It will be button-activated.
    Last edited by ChrisXcel; 05-20-2017 at 01:09 AM.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,576

    Re: Selecting cells based on current cells selected?

    Changed slightly
    Please Login or Register  to view this content.
    See the code in Sheet1 code module.
    Right click on sheet1 sheet tab - [View code]
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    02-14-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    328

    Re: Selecting cells based on current cells selected?

    Quote Originally Posted by jindon View Post
    Changed slightly
    Please Login or Register  to view this content.
    See the code in Sheet1 code module.
    Right click on sheet1 sheet tab - [View code]
    Yes your code works very nicely. Thank you!
    I will just have to figure out a way to combine it with a button, so that other
    steps can follow after the selection has been made.

    But I think I can build upon this!
    More tomorrow.

  6. #6
    Forum Contributor
    Join Date
    02-14-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    328

    Re: Selecting cells based on current cells selected?

    Thanks very much jindon for your help!
    I have been able to find a solution to my problem.

+ 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. Selecting specific range of cells based on current month
    By sohshak in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-26-2016, 11:14 AM
  2. [SOLVED] how do I assign current selected cells to variable ?
    By dschmitt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-06-2014, 09:39 PM
  3. Selecting Cells Each Side of a Selected Cell
    By Targetpin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-14-2014, 10:20 AM
  4. [SOLVED] If selected cells contain same number as current cell then...???
    By Schultze in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-28-2012, 02:21 PM
  5. Selecting rows of selected cells
    By jdskin2 in forum Excel General
    Replies: 2
    Last Post: 02-09-2012, 04:34 PM
  6. VBA code to add cells to a row based on values in current cells in the row
    By david_q in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-27-2012, 11:57 AM
  7. Fill selected cells by selecting a value from a list
    By davejcohen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-17-2010, 04:33 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