+ Reply to Thread
Results 1 to 6 of 6

SelectionChange and Dynamic Range. How to do it?

  1. #1
    Forum Contributor
    Join Date
    04-02-2017
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    405

    SelectionChange and Dynamic Range. How to do it?

    Hi guys,

    I want to have some code that activates when particular cells are selected within a dynamic range that Selectionchange can set.

    The range in which I want this code to run will change over time. I want my selectionchange to be able to find the bottom of a table (A4) and then have this code only run within the table and within columns B and C.
    Ie, not the whole of columns B and C, as I want to be able to have other things below this table that will not be affected).

    See code below.

    Thanks
    Jimmy


    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: SelectionChange and Dynamic Range. How to do it?

    Your example code doesn't do anything. So I'm a little confused what to are asking.

    This displays a message if you select any cell in columns B or C of the table..

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    04-02-2017
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    405

    Re: SelectionChange and Dynamic Range. How to do it?

    Hey Alpha Frog,

    Thanks for trying. You are correct the code wont do anything.. yet.
    • code that will run only within Range(B1,c??). The number of rows within the table will change. However I don't want the code to run for the whole of columns B and C.
    • code to run with selectionchange
    The below code defines a dynamic range that depends on the table's size. However since it has a "Select" in it, the code causes an infinite loop with the selectionchange and crashes.
    Please Login or Register  to view this content.
    I guess I need an alternative way to dynamically define a range.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: SelectionChange and Dynamic Range. How to do it?

    Quote Originally Posted by JimmyWilliams View Post
    Hey Alpha Frog,

    Thanks for trying. You are correct the code wont do anything.. yet.
    • code that will run only within Range(B1,c??). The number of rows within the table will change. However I don't want the code to run for the whole of columns B and C.
    • code to run with selectionchange
    The below code defines a dynamic range that depends on the table's size. However since it has a "Select" in it, the code causes an infinite loop with the selectionchange and crashes.

    The code I posted does exactly that (except for the infinite loop part).

  5. #5
    Forum Contributor
    Join Date
    04-02-2017
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    405

    Re: SelectionChange and Dynamic Range. How to do it?

    Quote Originally Posted by AlphaFrog View Post
    The code I posted does exactly that (except for the infinite loop part).
    Hi AlphaFrog,

    The code you pasted does work.. except it worked over the whole of Columns B and C, which is problematic in my case.

    I need the code to work only until.. say B50 C50... or say B10000, C10000, however not over the whole of both columns.
    The B50 C50/B10000 C10000 won't be determined until the SelectionChange starts running.

    Thank you for your time, I hope I have made problem I have a bit more clearer.

  6. #6
    Forum Contributor
    Join Date
    04-02-2017
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    405

    Re: SelectionChange and Dynamic Range. How to do it?

    Maybe...
    Maybe... you're right AlphaFrog..
    I'll have another look at it tonight, and will write back.

+ 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. Match ComboBox with dynamic range, then add Textbox1 to dynamic range
    By Lasse Moe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-07-2014, 01:26 AM
  2. [SOLVED] Set a single cell to start Selectionchange(ByVal Target As Range)
    By grantastley in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2013, 02:33 AM
  3. Fill Dynamic Range From Dynamic Source Range
    By goss in forum Excel General
    Replies: 2
    Last Post: 03-06-2012, 12:05 PM
  4. SelectionChange event on specific range only
    By chibouki in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2008, 02:40 AM
  5. In SelectionChange Make Last Rwo Dynamic
    By Robert in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-12-2006, 06:55 AM
  6. [SOLVED] Dynamic Range with unused formula messing up x axis on dynamic graph
    By cabybake@yahoo.com in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 02-02-2006, 04:10 PM
  7. Remember SelectionChange range in the Change sheet event?
    By Marie J-son in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2005, 06:06 AM

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