+ Reply to Thread
Results 1 to 3 of 3

Setting A Range variable That is Assigned Using xlDown (relative reference?) as the range

Hybrid View

catbeasy Setting A Range variable That... 09-01-2017, 02:47 PM
6StringJazzer Re: Setting A Range variable... 09-01-2017, 03:10 PM
catbeasy Re: Setting A Range variable... 09-01-2017, 05:43 PM
  1. #1
    Registered User
    Join Date
    07-08-2015
    Location
    Sacramento, CA
    MS-Off Ver
    2010
    Posts
    19

    Setting A Range variable That is Assigned Using xlDown (relative reference?) as the range

    ok, so I have code per below that I want to assign a range variable where the range is set using xlDown (is that considered 'relative reference' without the offset stuff?). Trouble is when I try to do that I get an error saying 'Object Required' (Run Time Error 424).

    I do have the 'Set' keyword as you can see, so I'm guessing this has something to do with using a relative reference(?) as the assigning piece of setting this range?

    Anyway, then I want to Count how much I get returned.

    Thanks for any help!

    Sub select_and_count()
    '
    ' select_and_count Macro
    '
    
    '
    
    Dim rngRange As Range
    Dim lngCnt As Long
    
    
    'Range(Selection, Selection.End(xlDown)).Select
    
    Set rngRange = Range(Selection, Selection.End(xlDown)).Select
    
    lngCnt = rngRange.Count
    
    MsgBox lngCnt
    
    
    End Sub

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner VA USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,456

    Re: Setting A Range variable That is Assigned Using xlDown (relative reference?) as the ra

    You are trying to do two different things on the same line of code. Remove the .Select:

    Set rngRange = Range(Selection, Selection.End(xlDown))
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    07-08-2015
    Location
    Sacramento, CA
    MS-Off Ver
    2010
    Posts
    19

    Re: Setting A Range variable That is Assigned Using xlDown (relative reference?) as the ra

    Cool, thanks so much!

+ 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. Setting Range Via Variable
    By WanderingJack in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-25-2015, 04:22 AM
  2. [SOLVED] Setting a variable range with a variable sheet name. Hmm?
    By starcraftbud in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-11-2013, 11:46 AM
  3. Replies: 15
    Last Post: 09-10-2013, 05:31 AM
  4. [SOLVED] Name Range - Relative Reference
    By Sultix in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-30-2012, 12:11 PM
  5. VBA range Selection with relative reference
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-29-2011, 12:39 PM
  6. setting a range variable
    By Lazhal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-30-2010, 01:50 PM
  7. Selecting a range with relative reference
    By HBF in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-12-2008, 04:45 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