+ Reply to Thread
Results 1 to 5 of 5

dynamic range

  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
    Please Login or Register  to view this content.
    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

    Please Login or Register  to view this content.
    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

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: dynamic range

    Please Login or Register  to view this content.
    Else if your just deleting the page content

    Please Login or Register  to view this content.
    Please take time to read the forum rules

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

    Re: dynamic range

    @Steffen, that was WAY simpler than what I would have guessed. Glad I asked-thank you!

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: dynamic range

    It would have assisted considerably if you had unprotected the worksheet first, or at least given us the password.

    Try using the .CurrentRegion property of cell A2.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

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

    Re: dynamic range

    Hmmm, I'm getting an object error at that line. (I tried it in an old version of my code) I'll try to figure out what I did wrong tomorrow. Leaving open until I figure out my mistake.

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