+ Reply to Thread
Results 1 to 9 of 9

Simple - Set range as first empty row in range

  1. #1
    Registered User
    Join Date
    11-20-2010
    Location
    Delaware, USA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Simple - Set range as first empty row in range

    Hi All,

    I have a real simple one that I think I'm making harder than it really is.

    I have a sheet where I have several shared users using a userform to enter data.
    To prevent them overwriting each other, I want to give each username a range. John is rows 3-22, Mike is rows 23-42, Mary is rows 43-62..
    Then I want it to find the first empty row within that range
    For instance:

    Please Login or Register  to view this content.
    The only thing I'm missing is how to specify the row to start on. The above code just finds an empty row, what do I add to make john start at row 3?

    Thanks!

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Simple - Set range as first empty row in range

    Here's a way assuming you don't allow blanks to occur within the range:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    11-20-2010
    Location
    Delaware, USA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Simple - Set range as first empty row in range

    Thanks!

    How would you write to the cells based off of that?

    When I do

    Please Login or Register  to view this content.
    I get Application-defined or object-defined error.
    Last edited by JBeaucaire; 01-28-2013 at 11:47 AM. Reason: Added code tags, as per forum rules. Don't forget!

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Simple - Set range as first empty row in range

    When you DEBUG and it highlights that line of code, hover your mouse over NR.... what is the value?

    This just worked perfectly for me:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-20-2010
    Location
    Delaware, USA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Simple - Set range as first empty row in range

    I copied your code but it doesn't change anything. The macro executes fine but it doesn't change any cell to "test".

  6. #6
    Registered User
    Join Date
    11-20-2010
    Location
    Delaware, USA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Simple - Set range as first empty row in range

    How about this:

    Please Login or Register  to view this content.
    The only problem with this is the 'Cells' line gives me the application/object-defined error.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Simple - Set range as first empty row in range

    I'm going to guess what you're describing as "empty" may not really be. I would certainly test the suggestions I've given in your workbook, if you wish. Click GO ADVANCED and use the paperclip icon to post up a copy of your workbook.

  8. #8
    Registered User
    Join Date
    11-20-2010
    Location
    Delaware, USA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Simple - Set range as first empty row in range

    I deleted all cells and ran it again. It worked. Except, it doesn't move down the range. I'd like if the macro is ran subsequent times, to goto the next 'empty' cell in that range.

    I attached a file with both codes in it.

    I appreciate all your help!
    Attached Files Attached Files

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Simple - Set range as first empty row in range

    Well poo, the SpecialCells method only works if there is something nearby to indicate non-blanks....me just being dumb. This seems to do what you want:

    Please Login or Register  to view this content.

+ 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