Still be able to send blank email with no data

hsolanki

Board Regular
Joined
Jan 16, 2020
Messages
153
Office Version
  1. 2010
Platform
  1. Windows
Hello I have an workbook whereby it has all the expiry dates and you can filter the each department which is on sheet2 filtered from sheet1 and show you any due dates for the selected department if there are any due dates and can send email based on filtered dates however problem is that although there are no expiry dates for selected filtered department you can still be able to send an email if there are no expiry dates.

i was wondering if there is any way we could avoid this e.g. if any of the department filtered and has got NO any due date then comes up with msgbox saying no new expiry date found for and the department name it was filtered for.

Thanks
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

MrTomasz

Board Regular
Joined
May 16, 2014
Messages
84
Office Version
  1. 365
Platform
  1. Windows
what about checking the last row in sheet2 after filtering?
if lastrow =1 (means no data below header) then msgbox and end
 

hsolanki

Board Regular
Joined
Jan 16, 2020
Messages
153
Office Version
  1. 2010
Platform
  1. Windows
Hi Tomasz thank you for promote respond would you help me with the code please as i would not know what to write
 

hsolanki

Board Regular
Joined
Jan 16, 2020
Messages
153
Office Version
  1. 2010
Platform
  1. Windows
Hi Tomasz i have tried below code but what it is doing when i filter the each department it is hiding the columns which has data. so when i select the department which has got data msgbox still comes up or when i tried with 1 then it will still sends out the blank email which has got no data.

VBA Code:
If lastrow = 0 Then
MsgBox "NO new Due dates"
Exit Sub
End If
 

Forum statistics

Threads
1,141,132
Messages
5,704,458
Members
421,351
Latest member
Sheogorath

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