Find next empty row ?

theta

Well-known Member
Joined
Jun 9, 2009
Messages
960
Hi

Anybody got a simple macro to find the next empty row, and make active cell column A of this row?

Also want it so that it only looks for empty rows AFTER row 14

Also, I have a seperate macro to input some formulas, how would I make it so that it will only run if the current row is higher than 14 ?

Help appreciated

T
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,484
This code is meant as a tutorial, perhaps you can modify to suit your needs..

Code:
Sub foo()
Dim nbr As Long 'nbr = Next blank row number
nbr = Range("A" & Rows.Count).End(xlUp).Row + 1
If nbr <= 14 Then
MsgBox "Your next Blank row is " & nbr & " , which is 14 or less"
Else
MsgBox "Your next blank row is " & nbr
End If
End Sub
 

theta

Well-known Member
Joined
Jun 9, 2009
Messages
960
Great, ill take a look. Think this uses column A only...but can adjust to see if a row range A:T is blank

Thanks!
 

theta

Well-known Member
Joined
Jun 9, 2009
Messages
960
Hmmm....still a bit stuck. Want to find the first row where the entire ROW is blank. This tutorial is using the contents of column A to determine a clean row

?
 

mancubus

Active Member
Joined
Mar 7, 2010
Messages
342
or


Code:
With ActiveSheet.UsedRange
      .Find(What:="", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate
End With
 

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841

ADVERTISEMENT

Hi, Luke
You could try this:-
Code:
[COLOR=navy]Sub[/COLOR] MG05Aug55
[COLOR=navy]Dim[/COLOR] Rng [COLOR=navy]As[/COLOR] Range, Dn [COLOR=navy]As[/COLOR] Range
[COLOR=navy]Set[/COLOR] Rng = Range("A1:A1000")
[COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] Dn [COLOR=navy]In[/COLOR] Rng
 [COLOR=navy]With[/COLOR] Application
    [COLOR=navy]If[/COLOR] Dn.Row > 14 And Len(Trim(Join(.Transpose(.Transpose(Dn.Resize(, Columns.Count)))))) = 0 [COLOR=navy]Then[/COLOR]
        MsgBox "Row " & Dn.Row
        [COLOR=navy]Exit[/COLOR] [COLOR=navy]Sub[/COLOR]
    [COLOR=navy]End[/COLOR] If
 [COLOR=navy]End[/COLOR] With
[COLOR=navy]Next[/COLOR] Dn
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
 

theta

Well-known Member
Joined
Jun 9, 2009
Messages
960
So which solution is more fool-proof and which is more efficient?
 

mancubus

Active Member
Joined
Mar 7, 2010
Messages
342
or


Code:
With ActiveSheet.UsedRange
      .Find(What:="", After:=.Cells([COLOR=red][B]15[/B][/COLOR], 1), LookIn:=xlValues, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate
End With

this (modified) code finds the first empty cell, starting from row 14, not the entire column.
 

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Hi, Luke
The best thing to do is is to test code for the result you want.
My code looks at each row after row 14, it joins all the values in each row, then trims the loose Spaces and then counts whats left. If it = 0 then the row is empty.
Regards Mick
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,699
Messages
5,833,206
Members
430,196
Latest member
rez5656

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
Top