+ Reply to Thread
Results 1 to 6 of 6

Dynamic Ranges....

  1. #1
    Registered User
    Join Date
    01-13-2008
    Posts
    19

    Dynamic Ranges....

    Hi,

    I have some vba code that does some sorting on a predefined range like so:

    Please Login or Register  to view this content.
    However, i no longer want the sort range of B5:U104 to be static as i want the user to be able to add new rows and when they click on the sort macro button, the sort picks up the newly added rows.

    Can anyone help me with this?

    Thanks in advance.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    This amendment should do that

    Please Login or Register  to view this content.
    Last edited by royUK; 01-14-2008 at 11:48 AM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    01-13-2008
    Posts
    19
    Thanks,

    however, it doesnt like that.

    Could it be because rngSortRange is first declared as a string but then initialized as something else i.e.

    ' Initialise range to sort
    strSortRange = Range("B5:U65536").End(xlUp)

    I don't know, im a beginner so that may be complete nonsense.

    Any ideas?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Yes, change it to Range. I would never use your strings to set ranges.

  5. #5
    Registered User
    Join Date
    01-13-2008
    Posts
    19
    Ammended as advised, but i get a 'run time error '1004' Application-defined or object-defined error'

    Please Login or Register  to view this content.
    Thanks

  6. #6
    Registered User
    Join Date
    01-15-2008
    Posts
    2
    ' Initialise range to sort
    Please Login or Register  to view this content.
    Can someone please tell me what the .End(xlUP) function refers to? How do I select this range to copy directly after I highlight it? I am such a newbie.
    Last edited by VBA Noob; 01-16-2008 at 02:50 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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