Increment using last row and first cell

cainey1991

New Member
Joined
Feb 20, 2014
Messages
31
Hi all,

I am looking for a simple function. I have managed to break it down into small chunks but not getting anywhere with it.

When the macro is run it looks at a table and increments the ID when it adds a row.
IDname
D-1
Bill
D-2Ben

<tbody>
</tbody>

I can add the row but cant increment the ID. I am trying to break it down :
1. Look at last value in the last row and first cell - cannot work out
2. Increment this value by 1

Any help would be great.

D
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
MAybe this



Excel 2010
AB
1IDname
2D-1Bill
3D-2Ben
4D -3
5D -4
Sheet1
Cell Formulas
RangeFormula
A4="D -" & RIGHT(A3,1)+1
A5="D -" & RIGHT(A4,1)+1
 
Upvote 0
Better



Excel 2010
AB
1IDname
2D-1Bill
3D-2Ben
4D -3
5D -4
6D -5
Sheet1
Cell Formulas
RangeFormula
A4="D -"& ABS(MID(A3,FIND("-",A3,1),99))+1
A5="D -"& ABS(MID(A4,FIND("-",A4,1),99))+1
A6="D -"& ABS(MID(A5,FIND("-",A5,1),99))+1
 
Upvote 0
It can be applied to VBA
Try
Code:
Private Sub worksheet_change(ByVal target As Range)
lr = Cells(Rows.Count, "B").End(xlUp).Row
If target.Count > 1 Then Exit Sub
If Intersect(target, Range("B2:B" & lr)) Is Nothing Then Exit Sub
x = 1
For r = 2 To lr
    Range("A" & r).Value = "D- " & x
    x = x + 1
Next r
End Sub
 
Upvote 0

Forum statistics

Threads
1,219,104
Messages
6,146,292
Members
450,685
Latest member
frederik00

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