Link to home
Start Free TrialLog in
Avatar of mikes6058
mikes6058

asked on

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
Avatar of Rgonzo1971
Rgonzo1971

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
Avatar of mikes6058

ASKER

I'm getting an error msg. See the link below for details

https://www.experts-exchange.com/questions/28692340/fix-send-attachement-VBA-code.html
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial