Quote Originally Posted by Greg M View Post
Hi Jessy,

I think I see your problem!

Your original workbook contained the code :

Private Sub CommandButton1_Click()
    SendEmail
End Sub


Public Function SendEmail()
Many lines of code here
End Function

Now, when you try to assign a routine to a button, the FUNCTION will not appear in the list of available macros (because it's not a "Sub" procedure), and the SUB will not appear because it's been declared as "Private".

So, either declare the SUB as a "Public" procedure, or (better!) convert the FUNCTION to a "Public Sub" procedure. Just use:
Public Sub SendEmail()

The "End Function" statement will be converted automatically to "End Sub".

This should allow the procedure to appear in the list of available macros so that you can assign it to whichever object you want.

Please let me know how you get on with this.

Regards,

Greg M
Hi Greg,

Thanks for that, have amended the macro as you advised and this has resolved that issue, however, a slight problem has arisen since.

After the email has been sent, the MsgBox “Your email has been sent” does not display as it did previously; instead there is a flashing Excel tab in the Taskbar and when opened it shows the form and the message, then when I click “OK” it stops flashing. Can we prevent this?

Also, would it be possible to have the ‘date of visit’ from cell E8 displayed next to the “Mail” on the subject line?

Once again many thanks for your time.

J