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
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