E-mail link

Niven

New Member
Joined
Aug 23, 2011
Messages
45
Hi,I have a worksheet where I am comparing two columns of data and if they don't match then it does not allow the user to close the file. This is the code I have and it works well. However I also have a button which takes the user to an outlook message for them to e-mail the current worksheet. Is there a way to link the two, so that if the user clicks the button it also won't allow him to e-mail and will give him the same error message? I have included below the macro for the e-mail button.Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim blnCancel As Boolean Dim rngCell1 As Excel.Range, rngCell2 As Excel.Range blnCancel = Not Sheets("Weekly Timesheet").Range("C44").Value If blnCancel Then Call MsgBox(Prompt:="Have ALL hours worked been allocated correctly?", Title:="Cannot close workbook", Buttons:=vbExclamation + vbOKOnly) End If Cancel = blnCancelEnd SubSub Send_via_email()'' Send_via_email Macro'' Application.Dialogs(xlDialogSendMail).ShowEnd Sub
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hi I have this code which gives the error message but it still opens a new Outlook message afterwards even though the numbers don't match
 
Upvote 0
Hi,I have a worksheet where I am comparing two columns of data and if they don't match then it does not allow the user to close the file. This is the code I have and it works well. However I also have a button which takes the user to an outlook message for them to e-mail the current worksheet. I am using this code. It works fine by giving the error message but then it still opens a new outlook message even though the number don't match:Sub Send_via_email()'' Send_via_email Macro' Dim rngCell1 As Excel.Range, rngCell2 As Excel.Range blnCancel = Not Sheets("Weekly Timesheet").Range("C44").Value If blnCancel Then Call MsgBox(Prompt:="Have ALL hours worked been allocated correctly?", Title:="Cannot send e-mail", Buttons:=vbExclamation + vbOKOnly)' If Cancel = blnCancel Then Application.Dialogs(xlDialogSendMail).ShowEnd Sub
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

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