Check Expiry dates from multiple sheets with a pop up box

Kjjb

New Member
Joined
Dec 26, 2022
Messages
13
Office Version
  1. 365
Platform
  1. Windows
Hi ,
Surely there must be a thread for my query , but cannot seem to find it .Appreciate your help.
I have a worksheet with 4 sheets named "D1D","D2D","D3D","Misc" . I need to write a VBA to check all the 4 sheets for expiry date ( today()-30) in column E ( range E 7:E135) and then pop message should state Certificates have expired. The pop up box/check should be done when I open the workbook.
Appreciate your help.

Thanks in advance
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
You don't have a sheet named as D2D.
Hi <

I have attached a screen shot pointing to the sheet named D2D( hope its correct) ....also the VBA works with sheets D1D,D2D & D3D ..but returns a run time error with sheets Misc & various.
Please assist
Thanks
 
Upvote 0
Hi <

I have attached a screen shot pointing to the sheet named D2D( hope its correct) ....also the VBA works with sheets D1D,D2D & D3D ..but returns a run time error with sheets Misc & various.
Please assist
Thanks
 

Attachments

  • Screenshot 2022-12-26 184901.jpg
    Screenshot 2022-12-26 184901.jpg
    179.6 KB · Views: 7
Upvote 0
I have a worksheet with 4 sheets named "D1D","D2D","D3D","Misc" .
It is because you have extra space in sheet name "Misc ". You should also add the name "Various" into the list if you want. You haven't mentioned in the first post.
VBA Code:
Private Sub Workbook_Open()
  Dim wsNames() As string
  wsNames = Split("D1D,D2D,D3D,Misc ,Various", ",") 'You must add the sheet names you want into this list.
  For i = 0 To 3
    With Worksheets(wsNames(i))
      For j = 7 to 135
        If .Cells(j, 5).Value > Now()-30 Then
          MsgBox "Sheet " & wsNames(i) & " Date E" & j & " has expired."
        End If
      Next
    End With
  Next
End Sub
 
Upvote 0
Guys Thanks a LOT !
All sorted out ..the sheet names had a space , hence it an error.

THANK YOU VERY MUCH FOR ALL THE HELP
 
Upvote 0
It is because you have extra space in sheet name "Misc ". You should also add the name "Various" into the list if you want. You haven't mentioned in the first post.
VBA Code:
Private Sub Workbook_Open()
  Dim wsNames() As string
  wsNames = Split("D1D,D2D,D3D,Misc ,Various", ",") 'You must add the sheet names you want into this list.
  For i = 0 To 3
    With Worksheets(wsNames(i))
      For j = 7 to 135
        If .Cells(j, 5).Value > Now()-30 Then
          MsgBox "Sheet " & wsNames(i) & " Date E" & j & " has expired."
        End If
      Next
    End With
  Next
End Sub
Yes you right .. THANK YOU ..MOST HELPFUL
 
Upvote 0
Hi Flashbond,
Sorry about this, the VBA you sent me worked perfectly. However I have inserted a few words in the rows E 38 & 72 for column E for the expiry date .hence the msg box keeps stating the dates have expired. Could you help to write a VBA to run a check on column E for the expiry dates but excluding cells E 38 & E 72.
I have attached the screen shot .
Thanks A LOT !
 

Attachments

  • Screenshot 2022-12-28 141124.jpg
    Screenshot 2022-12-28 141124.jpg
    44.7 KB · Views: 6
Upvote 0
How about this?
VBA Code:
Private Sub Workbook_Open()
  Dim wsNames() As string
  wsNames = Split("D1D,D2D,D3D,Misc ,Various", ",") 'You must add the sheet names you want into this list.
  For i = 0 To 3
    With Worksheets(wsNames(i))
      For j = 7 to 135
        If IsDate(.Cells(j, 5).Value) Then
          If .Cells(j, 5).Value > Now()-30 Then
            MsgBox "Sheet " & wsNames(i) & " Date E" & j & " has expired."
          End If
        End If
      Next
    End With
  Next
End Sub
 
Upvote 0
Perfect .. You a genius ! Thanks a lot

VERY MUCH APPRECIATED
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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