Message Box when opening Workbook

howard

Well-known Member
Joined
Jun 26, 2006
Messages
5,701
Office Version
  1. 2019
Platform
  1. Windows
I have setup the following code in the workbook module

If D25 on Sheet "Debtors" is greater than 0, the message box to pop up with message "Item has been processed" and if D25 is zero or blank then message to appear "Items not yet processed"

Where D25 is > 0 then message show "Item Processed" as well as "Item not yet processed"

message box only to show "Item not yet processed" if D25 is zero or blank

It would be appreciated if someone could kindly amend my code


Code:
 Private Sub Workbook_Open()
With Sheets("Sales")
If Range("D25") > "0" Then
MsgBox "Item processed"
Else
 End If

MsgBox "Item not yet processed"
End With

End Sub
 

Some videos you may like

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

StephenCrump

MrExcel MVP
Joined
Sep 18, 2013
Messages
4,046
Office Version
  1. 365
Platform
  1. Windows
The unqualified range reference Range("D25") will refer to the ActiveSheet. You need to say:

VBA Code:
With Sheets("Sales")
    If .Range("D25") > 0 Then
    '....
'OR

If Sheets("Sales").Range("D25") > 0 Then
    '...

I'm not clear about your processed/not processed logic, but at least your code and description are consistent. Do you need to allow for the possibility of negative values / text values?
 

howard

Well-known Member
Joined
Jun 26, 2006
Messages
5,701
Office Version
  1. 2019
Platform
  1. Windows
Thanks for the help. There value will always be positive, zero or blank
 

Watch MrExcel Video

Forum statistics

Threads
1,123,219
Messages
5,600,390
Members
414,381
Latest member
wizardofsloth

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
Top