Questions VBA code to create message box pop up for expiry dates

Wolfie82

New Member
Joined
Jun 28, 2023
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi, I have a list of Equipment description under B4 to B195 and expiring calibration due date which is in M4 to M195.

I wanted to have a msgbox popup message which shows the list of Equipment and dates which are 30 days near expiring.

Would appreciate if anyone could help.
 
Move the code out to another procedure you can run manually, i.e.
VBA Code:
Sub MyTest()
'   the body of all your code here
End Sub
Then step into that code and run it one step at a time, using the F8 key, and see where the error occurs.

Do you mean like this?

I pressed F8 manually and it loop a few times at the Loop through all Cells and then it stop with the error message on the line which i have highlighted.


1688095771028.png
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
It sounds like that you have some values in the range M4:M195 that are NOT date entries.
Do you perhaps have some text or error entries in that range?
 
Upvote 0
Hi Joe,
It seems that there are some "-" which does not recognize as date. I have already deleted them away.
Now it can run the code but it won't shows the equipment which is less than 30 days of the expiry date.
It keep showing "No equipment with expiration dates in the next 30 days."

Here is the example how to table looks like.

1689039972889.png
 
Upvote 0
Your image does not match your original requirements.
You said Due Date was in column M, but your image shows column F.
Did you adjust the code for that?
 
Upvote 0
Your image does not match your original requirements.
You said Due Date was in column M, but your image shows column F.
Did you adjust the code for that?
Hi Joe,
yes I have adjusted the code from column M to F. This is just a example to show you how the table looks like.

Is there anyway to ignore "-" in the due date and still get the same results?
 
Upvote 0
Can you post your current version of the code, with your updates, and post your sample data in a manner which allows me to copy it to my Excel spreadsheets (cannot copy screen prints and paste into Excel as workable data)?

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Hi Joe,

Thanks for helping. After tweeting the code, I finally get it working.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

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