Create a unique ID on the next line

CaptianMorgan

New Member
Joined
Apr 10, 2018
Messages
1
Hello All,
I am new to the Macro and VBA scene. I am working on a project for a friend. I am currently using a user form to take inputs. I already have it finding the first free cell with this code:

'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1

But what I am trying to have it do is take an input (InputID.value) and adding it to the current row number (So that it is always a unique number) and sticking that value and number into the same cell. I can get it to grab the input and then use the prevous cell value to create a new value but when they add a letter to the ID the formula cannot find a number. Here is that code:

Test = "Test"
ActiveCell.Formula = "=MAX(A2:A" + CStr(ActiveCell.Row - 1) + ")+1"
ActiveCell.Formula = Test & ActiveCell.Value

If you could be so kind to help me understand to take my InputID.value (in the above case Test) add the row number to it and spit it out. So InputID.Value = ABC and the next free cell is A4 The output I want is ABC4. Then when I go to enter the next inputID.Value (CBA) it is CBA5.

Just so I am covering all bases InputID.Value is a variable from a userform input and the number added is the row number. Is this possible?

Thank you all in advance for your help
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,224,802
Messages
6,181,054
Members
453,014
Latest member
Chris258

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