apply next number in newly inserted row

  • Thread starter Thread starter KUMPFfrog
  • Start date Start date
K

KUMPFfrog

I have a CommandButton that Inserts a row in a particular location. I would
now like to continue the macro to search col B for the highest number and
then apply the next number to cell of col B in row just inserted. Note - the
numbers in col B are not always in order on the list.

Thanks for any help given
 
The key is that once you have inserted a row, the activecell will be in that
row:

Sub put_it()
ActiveCell.EntireRow.Insert
Set b = Range("B:B")
Cells(ActiveCell.Row, "B").Value = Application.WorksheetFunction.Max(b) + 1
End Sub
 
Perfect! Thank you!

Gary''s Student said:
The key is that once you have inserted a row, the activecell will be in that
row:

Sub put_it()
ActiveCell.EntireRow.Insert
Set b = Range("B:B")
Cells(ActiveCell.Row, "B").Value = Application.WorksheetFunction.Max(b) + 1
End Sub
 
Back
Top