save and send VBA code

The attached excel file contains a macro called "delete columns". The macro will delete a select group of columns. It will then move and copy the new data excluding the deleted columns to a new work book.

Could someone please add some code to the macro so the new workbook is then automatically saved as "member_database" and attached to an email. I will be manually entering a different email address each time the sheet is sent so the macro can stop at this stage.

Added bonus:
I do not want to save any changes to the original workbook. If anyone can add a line to the macro which also closes the original workbook without saving. It would be a great help

Thanks
Mike
delete.save.send.xlsm
mikes6058Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

pls try

Sub deletecolumns()
'
' deletecolumns Macro
'

'

    Columns("A:F").Delete Shift:=xlToLeft
    ActiveWindow.SmallScroll ToRight:=13
    Columns("P:Q").Delete Shift:=xlToLeft
    Columns("Q:Q").Delete Shift:=xlToLeft
    Columns("R:CX").Delete Shift:=xlToLeft
    Sheets("Database").Copy
    ActiveWorkbook.SaveAs ActiveWorkbook.Path & "\" & "member database.xlsm"
    Res = InputBox("Enter E-mail")
    ActiveWorkbook.SendMail Recipients:=Res
End Sub

Open in new window

Regards
0
mikes6058Author Commented:
I'm getting an error msg. See the link below for details

http://www.experts-exchange.com/questions/28692340/fix-send-attachement-VBA-code.html
0
Rgonzo1971Commented:
Hi,

then try

 Sub deletecolumns()
 '
 ' deletecolumns Macro
 '

 '
     Set wkb = ActiveWorkbook
     Columns("A:F").Delete Shift:=xlToLeft
     ActiveWindow.SmallScroll ToRight:=13
     Columns("P:Q").Delete Shift:=xlToLeft
     Columns("Q:Q").Delete Shift:=xlToLeft
     Columns("R:CX").Delete Shift:=xlToLeft
     Sheets("Database").Copy
     ActiveWorkbook.SaveAs ActiveWorkbook.Path & "\" & "member database", xlOpenXMLWorkbook
     Res = InputBox("Enter E-mail")
     ActiveWorkbook.SendMail Recipients:=Res
     wkb.Close False
 End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.