find missing value or last value and increment

kamranyd

Board Regular
Joined
Apr 24, 2018
Messages
152
Office Version
  1. 2021
Platform
  1. Windows
Code:
[COLOR=#E56717][FONT=Consolas][B]Sub[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] add()[/FONT][/COLOR]
[COLOR=#151B8D][FONT=Consolas][B]Dim[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] v [/FONT][/COLOR][COLOR=#151B8D][FONT=Consolas][B]As[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] Workbook, cellValue [/FONT][/COLOR][COLOR=#151B8D][FONT=Consolas][B]As [/B][/FONT][/COLOR][COLOR=#F660AB][FONT=Consolas][B]String[/B][/FONT][/COLOR]

[COLOR=#8D38C9][FONT=Consolas][B]With[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] Worksheets([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"Sheet2"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas])[/FONT][/COLOR]
[COLOR=#141414][FONT=Consolas]    cellValue = .Range([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"A"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas] & .Cells(.Rows.Count, [/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"A"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas]).[/FONT][/COLOR][COLOR=#8D38C9][FONT=Consolas][B]End[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas](xlUp).Row).Value[/FONT][/COLOR]
[COLOR=#8D38C9][FONT=Consolas][B]End[/B][/FONT][/COLOR][COLOR=#8D38C9][FONT=Consolas][B]With[/B][/FONT][/COLOR]
[COLOR=#141414][FONT=Consolas]    ActiveSheet.Range([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"A1"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas]).Value = Format$((Right$(cellValue, 3) + 1))[/FONT][/COLOR]
[COLOR=#8D38C9][FONT=Consolas][B]End[/B][/FONT][/COLOR][COLOR=#E56717][FONT=Consolas][B]Sub[/B][/FONT][/COLOR]

i m using these codes but there is 1 problem with these codes is that it check last number and increment, can it can also check if any number is missing in between. for example if it is checking number from 1 to 10 and 7 or 4 any number is missing it show that number else it find last number and increment.
 
Last edited:

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,216,031
Messages
6,128,422
Members
449,450
Latest member
gunars

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