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
 

Some videos you may like

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,471
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
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,993
Messages
5,514,672
Members
409,014
Latest member
evenyougreg

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top