Results 1 to 5 of 5

dynamic range

Threaded View

  1. #1
    Registered User
    Join Date
    08-31-2011
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2003/Excel 2007
    Posts
    37

    dynamic range

    This is related to a question I asked earlier. My original code used
    'With Sheets("SORT DATA")
    '    .Range("A2:O" & .Range("A2").End(xlDown).Row) = ""      'delete data from SORT to reduce file size
    'End With
    After some trouble shooting on a weird looking plot, I found that when I went back to clear the data, it was missing some rows because the first column was blank but there was data in the second and third columns. This data wasn't deleted and kept getting carried over (and counted repeatedly in a later function). So I changed the code to

    'With Sheets("SORT DATA")
    '    .Range("A2:O" & .Range("C2").End(xlDown).Row) = ""      'delete data from SORT to reduce file size
    'End With
    which solves my original problem. I moved the reference to the column that will ALWAYS have the most data in it.

    So I am curious, just for future reference, what if you don't know which column will be the longest? Would the best way be to count the data in each column to find the longest, then set the dynamic range to reference that column?

    This doesn't apply to anything I am doing, but as I was testing and reviewing my coding, it made me wonder how to handle that issue if I needed to. The workbook I am posting has the original data I was working with, which has three columns of varying length data-just something to illustrate the question.
    Attached Files Attached Files

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.6.0 RC 1