+ Reply to Thread
Results 1 to 4 of 4

VBA to select a data set - not hard code it

Hybrid View

  1. #1
    Registered User
    Join Date
    02-28-2008
    Posts
    15

    VBA to select a data set - not hard code it

    I'm trying to automate weekly reports so I don't want my ranges to be hard coded the size of data sets will vary from week to week.

    Although
    Range("A1:E89").Sort
    works fine for this week, next week may need ("A1:E95")

    The data will always be in columns A:E but and there is no blank cells but the number of rows will vary.

    Can anyone sugeest a piece of code that will select just the data set?

    Thank to anyone who takes time to consider this

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    Try

    Range("A1").CurrentRegion.Sort

  3. #3
    Registered User
    Join Date
    02-28-2008
    Posts
    15
    That's perfect!


    Thank you!

  4. #4
    Forum Contributor
    Join Date
    03-25-2008
    MS-Off Ver
    Excel, Outlook, Word 2007/2003
    Posts
    245
    Quote Originally Posted by mrice
    Try

    Range("A1").CurrentRegion.Sort
    'column A is always filled in
    Range("A1:E" & Range("A" & Rows.Count).End(xlUp).Row).Sort
    I believe the current region isn't updated until the workbook is saved. Could be wrong off course.

    Charlize

+ 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