+ Reply to Thread
Results 1 to 5 of 5

Thread: How to set a range based on area selected using mouse?

  1. #1
    Valued Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2007
    Posts
    345

    How to set a range based on area selected using mouse?

    I'm sure this is a simple one liner, but it escapes me (as do most things).

    I'm trying to set a variable for a range based on the cells selected. For example, I want variable "myrange" to be set to range("A1:D14") if I click on cell A1 and drag it to D14.

    So far everything I've tried ends up getting the good old "1004 - Application defined or object defined error"

    Thanks!
    Last edited by JP Romano; 10-02-2009 at 11:08 AM. Reason: I'm an idiot

  2. #2
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: How to set a range based on area selected using mouse?

    Do you mean

    Dim myRange As Range
    Set myRange = Selection
    'do stuff
    Set myRange = Nothing

  3. #3
    Valued Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2007
    Posts
    345

    Re: How to set a range based on area selected using mouse?

    Talk about a real dummy mistake...I'm actually embarrased to elaborate. Thank you, as always.

  4. #4
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: How to set a range based on area selected using mouse?

    At least now you know it's Friday...

  5. #5
    Valued Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2007
    Posts
    345

    Re: How to set a range based on area selected using mouse?

    Thanks... lack of sleep must be taking it's toll!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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.2.0