Not saving if a Member's Property is incorrect

jackyysteez

New Member
Joined
Jul 17, 2018
Messages
8
Hello, I'm fairly new to VBA and was given the task to disable the save function in EPM in accordance with when the Range C27's member property does not equal LOB_400

I have two codes...
Code:
Function BEFORE_SAVE()
 
    If Range("A14").Value <> "LOB_400" Then
        BEFORE_SAVE = False
        MsgBox "Incorrect Cost Center. No Data was saved. Please select a cost center in LOB_400", vbAbortRetryIgnore
    Else
        MsgBox "Are you sure you want to Save this data?", vbOKCancel
        BEFORE_SAVE = True
    End If
End Function

This code completely works for my task, however, I had to corrupt cell A14 by putting the EPM Member Property formula into it... In efforts to rid my report of my tampering with cell A14... My second set of code is...

Code:
Function BEFORE_SAVE()
    If WorksheetFunction.Proper(Range("C27")) <> "LOB_400" Then
        BEFORE_SAVE = False
        MsgBox "Incorrect Cost Center. No Data was saved. Please select a cost center in LOB_400", vbAbortRetryIgnore
    Else
        MsgBox "Are you sure you want to Save this data?", vbOKCancel
        BEFORE_SAVE = True
    End If
End Function
Any idea on why when I try to run this code I am not getting the same results as I would for the first set of code??
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
You're comparing proper case value (Lob) to an upper case value(LOB) so it will never match.
try either of these
Code:
If WorksheetFunction.Proper(Range("C27")) <> "Lob_400" Then
Code:
If Ucase(Range("C27")) <> "LOB_400" Then
 
Upvote 0
I realize now that I am using the wrong worksheet function, what worksheet function do i want to use so that the function picks up the cells Property, not its value
 
Upvote 0
I'm sorry I don't understand what you mean.
I have never heard of anyone talking about a cells property in excel before.
 
Upvote 0
What are/is 'LOB, LOB_400'?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,553
Messages
6,120,184
Members
448,949
Latest member
keycalinc

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