+ Reply to Thread
Results 1 to 5 of 5

Detecting Column selected from cell or range of cells

  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,163

    Detecting Column selected from cell or range of cells

    I am trying to set up a macro to ensure only a cell or cells in Column C are selected by the user (Mouse).
    The problem I am stumbling on is extracting the Column letter ("C") from "myRng".

    I seem to be reading the cell contents rather than the cell or cells range.
    Example cell contents:
    Please Login or Register  to view this content.
    Any help is appreciated.

    Please Login or Register  to view this content.
    (Acknowledgement: Most of the Macro is from a forum member whom helped me out)
    Regards

    Rick
    Win10, Office 365

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Detecting Column selected from cell or range of cells

    Please Login or Register  to view this content.
    Without a qualifier, you're reading the default property of a range, which is its value. Try
    Please Login or Register  to view this content.

  3. #3
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2402-17328.20068
    Posts
    1,359

    Re: Detecting Column selected from cell or range of cells

    Some examples of getting column info from a given range:
    Please Login or Register  to view this content.
    If things don't change they stay the same

  4. #4
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,163

    Re: Detecting Column selected from cell or range of cells

    Thank you for clarifying what I was doing wrong.
    With the qualifier, I am still not capturing the Column Letter.
    Which is where I am stuck.

    Attached is a sample excel XLSM file.
    Attached Files Attached Files
    Last edited by Rick_Stanich; 06-15-2022 at 09:37 AM. Reason: Added attachment

  5. #5
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2402-17328.20068
    Posts
    1,359

    Re: Detecting Column selected from cell or range of cells

    That will be because 'Left(myRng.Address, 1)' = $

    Try:
    Please Login or Register  to view this content.
    End column would be:
    Please Login or Register  to view this content.
    If you wanted to use the other method then you would need to turn off the absolute part of the range.address:
    Please Login or Register  to view this content.
    I would not recomend this as what if the column in question was AA? The second A would be lost.
    Last edited by CheeseSandwich; 06-15-2022 at 09:44 AM.

+ 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. Detecting which other cells are affected by a cell
    By Kiredoryor in forum Excel General
    Replies: 6
    Last Post: 03-28-2019, 11:31 AM
  2. Button that inserts a text into a selected cell or a range on selected cells
    By gorely84 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-21-2018, 10:47 PM
  3. Sort / subsort a range of cells based on the cell selected ??
    By James_36 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-23-2018, 08:01 AM
  4. [SOLVED] Can hidden cells still be selected via range and cell?
    By Granite-Granny in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-12-2014, 01:15 PM
  5. [SOLVED] Matching cell content against selected cells - not range
    By ghoneim in forum Excel General
    Replies: 7
    Last Post: 05-02-2013, 03:50 AM
  6. Defining a range to highlight column and row in line with selected cell
    By ACM2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-19-2012, 11:13 PM
  7. Detecting if only one row is selected, have problem with the Cntrl key
    By buran in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2009, 04:02 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