+ Reply to Thread
Results 1 to 4 of 4

Store selected rows, then pass the row range to a With For Loop.

  1. #1
    Registered User
    Join Date
    12-20-2014
    Location
    North America
    MS-Off Ver
    2013
    Posts
    40

    Store selected rows, then pass the row range to a With For Loop.

    Rather than have the user manually write, "E3:E10", for the following block of code:

    Please Login or Register  to view this content.
    I would like VBA to read the range of cells stored when a user, uses their mouse to select E3:E10 on the worksheet. From there I'd like to pass it with CStr, if necessary, into the argument of 'For Each cell In Range'

    The following statement, is only capable of recognizing one cell at a time, and it doesn't store the absolute cell location, i.e. E3, but the displayed value.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Store selected rows, then pass the row range to a With For Loop.

    Selection will return all the selected cells.

    What is it you want to do here?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-20-2014
    Location
    North America
    MS-Off Ver
    2013
    Posts
    40

    Re: Store selected rows, then pass the row range to a With For Loop.

    Please Login or Register  to view this content.
    I'd like "E3:E10" to be displayed; to let me know the previous statements are working as intended.

    The following worked, .Address had to be included:
    Please Login or Register  to view this content.
    If one could tell me how to retrieve, or store "E3:E10" when a user selects these 7 cells with their mouse, it would be appreciated..

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Store selected rows, then pass the row range to a With For Loop.

    If you want to store the address in G3 use the Address property.
    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)

Similar Threads

  1. Replies: 7
    Last Post: 03-12-2017, 03:20 PM
  2. [SOLVED] How to pass text store in Classes, to other module
    By alexnkc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-04-2016, 12:11 AM
  3. VBA code to loop through a range of selected cells, to add to my macro
    By craig schultz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-27-2014, 10:30 AM
  4. Loop backwards through selected range - delete entire row from selected cells
    By scottbass in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-20-2014, 09:21 AM
  5. Use if statement for a range +4 and -4 and write PASS / NOT PASS
    By alexistkd in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-05-2013, 07:11 PM
  6. to iterate within selected range and loop
    By dazzwilliams in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-22-2011, 01:27 AM
  7. loop to copy selected rows to a new sheet
    By katey in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-08-2005, 10:01 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