VBA If OR stmt encounteringsyntax error

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!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,223,912
Messages
6,175,340
Members
452,637
Latest member
Ezio2866

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