ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   apply next number in newly inserted row (https://www.excelbanter.com/excel-programming/422966-apply-next-number-newly-inserted-row.html)

KUMPFfrog

apply next number in newly inserted row
 
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

Gary''s Student

apply next number in newly inserted row
 
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

--
Gary''s Student - gsnu200828


"KUMPFfrog" wrote:

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


KUMPFfrog

apply next number in newly inserted row
 
Perfect! Thank you!

"Gary''s Student" wrote:

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

--
Gary''s Student - gsnu200828


"KUMPFfrog" wrote:

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



All times are GMT +1. The time now is 12:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com