Try this.
Private Sub SubmitButton_Click()
'Validating that the user is sure they woud like to submit
Dim Answer As Integer
Answer = MsgBox("Are you sure you are ready submit the data?", vbYesNo + vbQuestion, "Submit New Entry")
'Transfer data into the worksheet
Dim emptyRow As Long
Sheet1.Activate
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 5
If Answer = vbYes Then
Cells(emptyRow, 1).Value = TradingNameText.Value
If licencetext.Value = True Then Cells(emptyRow, 2).Value = "FB" & licencetext.Value
If licencetext.Value = False Then
For Each cl In Range("B6", Range("B" & Rows.Count).End(xlUp))
If cl.Value <> vbNullString Then
mymax = Application.Max(mymax, ExtractNumber2(cl.Value))
End If
Next
Cells(emptyRow, 2).Value = "FB" & mymax + 1
End If
Else
'do nothing
End If
Unload Me
End Sub
Function ExtractNumber2(rC As String) As Long
With CreateObject("VBSCRIPT.REGEXP")
.Pattern = "[^0-9]"
.Global = True
.IgnoreCase = True
ExtractNumber2 = .Replace(rC, "")
End With
End Function
Bookmarks