Message Box when opening Workbook

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,561
Office Version
  1. 2021
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
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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?
 
Upvote 0
Thanks for the help. There value will always be positive, zero or blank
 
Upvote 0

Forum statistics

Threads
1,214,592
Messages
6,120,433
Members
448,961
Latest member
nzskater

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