Find next blank row but not past row 35?

Margate

New Member
Joined
Mar 15, 2013
Messages
21
Hello Everyone,

I want a macro that will find the last blank row but only up to row 35 (not beyond row 35). I found the below macro online
and it works very well but on my spreadsheet it will go past row 35! The range I want to look in is from cell B11 down to
cell B35. I need to select the first cell within that range that does not contain and data...


Perhaps the below code is able to be modified to not search past row 35?:

nextrow = Cells.Find(what:="*", searchdirection:=xlPrevious, searchorder:=xlByRows).Row + 1
Cells(nextrow, 2).Select


Thank you in advance for any help.

Margate
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi Margate and Welcome to the Board,

Here's one way...

Code:
Sub FindFirstBlankInRange()
    Dim rFound As Range

    
    With Range("B11:B35")
        Set rFound = .Find(What:="", After:=.Cells(.Rows.Count, 1), _
            LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlNext)
    End With

    
    If rFound Is Nothing Then
        MsgBox "No blanks in this range"
    Else
        MsgBox "first blank is cell: " & rFound.Address
    End If
End Sub

Edit: The above code will find the first blank cell, even if it has a formula that returns a blank.
If you want the first empty cell, modify this line to read...
Code:
Set rFound = .Find(What:="", After:=.Cells(.Rows.Count, 1), _
            LookIn:=xlFormulas, LookAt:=xlWhole, SearchDirection:=xlNext)
 
Last edited:
Upvote 0
Wow!
I would never had been able to work that out!
Thank you very much for your help. It worked perfectly. You must be an Excel genius! :)
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,876
Members
449,056
Latest member
ruhulaminappu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top