jackyysteez
New Member
- Joined
- Jul 17, 2018
- Messages
- 8
So I'm new to VBA but I was given the task to make it so if somebody puts the wrong cost center into cell C27 and it does not fall into the right LOB category, a message box pops up and tells you you may not save due to cost center entry. The code should also cancel the save action unless a correct Cost Center is provided. So far my code is...
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Public Property Get CostCenter() As String
Set CostCenter = Range("C27")
strCostCenter = obj.CostCenter
variable = Object.Property
CostCenter.Select.GetPropertyList
If CostCenter <> LOB_400 Then
MsgBox "Wrong Cost Center provided!", vbCancel
Cancel = True
Else: Cancel = False
End If
End Property
End Sub
However I am having immense trouble with it as every time i try and run it a Pop Up occurs asking me to name the Macro.. Let me know what you guys think, Thank you!!
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Public Property Get CostCenter() As String
Set CostCenter = Range("C27")
strCostCenter = obj.CostCenter
variable = Object.Property
CostCenter.Select.GetPropertyList
If CostCenter <> LOB_400 Then
MsgBox "Wrong Cost Center provided!", vbCancel
Cancel = True
Else: Cancel = False
End If
End Property
End Sub
However I am having immense trouble with it as every time i try and run it a Pop Up occurs asking me to name the Macro.. Let me know what you guys think, Thank you!!