Disable Save when Cost Center does not fall into the correct LOB

Status
Not open for further replies.

jackyysteez

New Member
Joined
Jul 17, 2018
Messages
8
I am fairly new to VBA and was given the task to disable the save feature on EPM if a Cost Center is an incorrect value, creating an incorrect LOB. I need the Cost Centers EPMMemberProperty to be equal to LOB_400 in order for it to save, and if it is not I need it to cancel. The data provided in Cell C27 gives a numerical value of the Cost Center but not it's LOB, so far my code looks like this..

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Private Property Get CostCenter() As String
Set CostCenter = Range("C27")
Set CostCenter.Name = Property.Name
strCostCenter = obj.CostCenter

CostCenter.Select.GetPropertyList
If CostCenter.Name <> LOB_400 Then
MsgBox "Wrong Cost Center provided!", vbCancel
Cancel = True
Else: Cancel = False
End If

End Property
End Sub

However, when I try and run it a Pop Up comes up about Naming the Macro... Any tips/words of advice would be gratefully appreciated! Thank You!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Status
Not open for further replies.

Forum statistics

Threads
1,214,911
Messages
6,122,194
Members
449,072
Latest member
DW Draft

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