+ Reply to Thread
Results 1 to 6 of 6

Thread: Find next blank row even if there is a formula in that row

  1. #1
    Registered User
    Join Date
    05-28-2011
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2010
    Posts
    4

    Find next blank row even if there is a formula in that row

    I have coded a userform that enters data into the next available blank row but if there is a formula in that row then it wont enter it in that row, I would like to add data to rows that also contain formulas that produce a blank result. Here is the current code that I am using:

    lRow = ws.Cells(Rows.Count, 1) _
      .End(xlUp).Offset(1, 0).Row
    Thankyou in advance.
    Deb.
    Last edited by dlhslim; 06-12-2011 at 02:09 AM.

  2. #2
    Forum Guru Domski's Avatar
    Join Date
    12-14-2009
    MS-Off Ver
    What does it matter?
    Posts
    3,933

    Re: Find next blank row even if there is a formula in that row

    Maybe:

    Dim lngLastRow As Long
    lngLastRow = Cells.Find("*", LookIn:=xlValues, SearchDirection:=xlPrevious).Row + 1

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    05-28-2011
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Find next blank row even if there is a formula in that row

    Hi Dom,
    Thanks for your code, however it still entered the data into the next row that didn't contain a formula, but I want it to add it to the next row that does contain a formula. The formula is in Column A & my data is entered into Columns B & onwards.

  4. #4
    Forum Guru Domski's Avatar
    Join Date
    12-14-2009
    MS-Off Ver
    What does it matter?
    Posts
    3,933

    Re: Find next blank row even if there is a formula in that row

    Rather than checking column A for the last row can you not check B then?

    Row = ws.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Row

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  5. #5
    Registered User
    Join Date
    05-28-2011
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2010
    Posts
    4

    Smile Re: Find next blank row even if there is a formula in that row

    Thanks Dom, this worked perfectly, only change I had to make to this code of yours was to add a new line from .End & an underscore after the cells, see eg. below:

    Quote Originally Posted by Domski View Post
    Rather than checking column A for the last row can you not check B then?

    Row = ws.Cells(Rows.Count, 2) _
    .End(xlUp).Offset(1, 0).Row

    Dom

  6. #6
    Forum Guru Domski's Avatar
    Join Date
    12-14-2009
    MS-Off Ver
    What does it matter?
    Posts
    3,933

    Re: Find next blank row even if there is a formula in that row

    No worries.

    I assume you know that isn't an integral part of the code, just a method of spreading long lines of code onto more than one line to make them easier to read?

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

+ 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.2.0