vba - Send selection from Excel by email as attachment -


i using macro send workbook attachment (book1.xlsx)

sub macro2_sendbyemail()  ' copy sheet(1) thisworkbook.sheets(1).copy  ' send email activeworkbook .sendmail recipients:=array("address@company.com", "address2@company"), subject:="addresses [" & format(date, "dd/mm/yy") & "]" .close savechanges:=false end  end sub 

but cannot find out how edit code send first 3 columns of workbook...

thanks help!

you may try out:

option explicit  sub macro2_sendbyemail()  ' copy sheet(1)     dim my_range    range     dim l_row       long      l_row = thisworkbook.sheets(1).usedrange.rows.count     thisworkbook.sheets(1)         set my_range = .range(.cells(1, 1), .cells(l_row, 3))     end      my_range.copy      ' send email     activeworkbook     .sendmail recipients:=array("address@company.com", "address2@company"), subject:="addresses [" & format(date, "dd/mm/yy") & "]"     .close savechanges:=false     end  end sub 

the idea take last row of used range in first sheet, , based on define selection copy.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -