dmqueen
Board Regular
- Joined
- Aug 5, 2014
- Messages
- 53
Please help!
I am trying to generate new part numbers which include a separator which is usually -0-, but n 9 special cases is -1-. I've tried putting the special cases in an If OR stmt. with and without repeating the testing field but can't get past a syntax error! Here is my function:
Public Function fGenerateNextPartNumber(LastPartIn As String) As String
Dim LastPartNo As String
LastPartNo = LastPartIn
'LastPartNo = ActiveCell.Value
Dim NewStrPartNo As String
Dim strPartNo As String
strPartNo = ActiveSheet.Name()
Dim strSeperator0 As String
Dim strSeperator1 As String
Dim strLastSeqPartNo As String
'debugging
Call MsgBox(LastPartIn)
strLastPartNo = (Right(LastPartIn, 4))
'debugging
Call MsgBox(LastPartNo)
Dim strNewSeqPartNo As String
Dim intNewSeqNo As Integer
Dim intLastSeqNo As Integer
'handle special case separators HERE!
intLastSeqNo = CInt(strLastPartNo)
intNewSeqNo = LastSeqNo + 1
If strPartNo ="180" OR "300" OR = 310" OR = "320" OR "330" OR "970" OR = "681" OR "981" Then
StrSeparator = "-1-"
Else: StrSeparator = "-0-"
End If
NewStrPartNo = strPartNo + StrSeparator + CStr(intNewSeqNo)
Return NewStrPartNo
End Function
I've also tried the line:
If strPartNo ="180" OR strPartNo = "300" OR strPartNo = "310" OR =strPartNo = "320" OR strPartNo = "330" OR "strPartNo =970" OR = strPartNo ="681" OR strPartNo = "981"
But got the same error Argh!
I am trying to generate new part numbers which include a separator which is usually -0-, but n 9 special cases is -1-. I've tried putting the special cases in an If OR stmt. with and without repeating the testing field but can't get past a syntax error! Here is my function:
Public Function fGenerateNextPartNumber(LastPartIn As String) As String
Dim LastPartNo As String
LastPartNo = LastPartIn
'LastPartNo = ActiveCell.Value
Dim NewStrPartNo As String
Dim strPartNo As String
strPartNo = ActiveSheet.Name()
Dim strSeperator0 As String
Dim strSeperator1 As String
Dim strLastSeqPartNo As String
'debugging
Call MsgBox(LastPartIn)
strLastPartNo = (Right(LastPartIn, 4))
'debugging
Call MsgBox(LastPartNo)
Dim strNewSeqPartNo As String
Dim intNewSeqNo As Integer
Dim intLastSeqNo As Integer
'handle special case separators HERE!
intLastSeqNo = CInt(strLastPartNo)
intNewSeqNo = LastSeqNo + 1
If strPartNo ="180" OR "300" OR = 310" OR = "320" OR "330" OR "970" OR = "681" OR "981" Then
StrSeparator = "-1-"
Else: StrSeparator = "-0-"
End If
NewStrPartNo = strPartNo + StrSeparator + CStr(intNewSeqNo)
Return NewStrPartNo
End Function
I've also tried the line:
If strPartNo ="180" OR strPartNo = "300" OR strPartNo = "310" OR =strPartNo = "320" OR strPartNo = "330" OR "strPartNo =970" OR = strPartNo ="681" OR strPartNo = "981"
But got the same error Argh!