Combining Two sets of Code - Save as a particular file name based on info in file & email to set person

Chelsea0270516

New Member
Joined
Oct 15, 2015
Messages
32
Hello!

I haven't written any code myself yet. But I have used recording macros & lots of google searches to get a few time savers for some of the work I do.

I have one set of code that works to delete my autolook ups (basically it copy & pastes special so no vlookups are left), then it saves the doc to a particular location, with a name that is specific to the data I put in the document. It also saves without macros enabled & closes the document.

My second set of code was written by someone on here (I saw it this morning actually!). It does something (which I cut cut out because I didn't need it) & then prompts outlook to email a specific person.

I am wondering - could someone help me figure out how to combine the two sets of code to make a different set that does the following:


  1. Automatically saves the document with the following format
    1. [Contents of C14]&"-WHSE130-Display Order CMM-"&Today()
    2. Today in MMDDYY format
    3. Example: 2211-WHSE130-Display Order CMM-042216
  2. It needs to be saved in a particular location.
  3. It needs to be saved as a basic workbook (no macros enabled)
  4. It needs to email me once it is saved with the item attached & the name of the document as the subject of the email.

I am using an existing form & can't add in any lines to the excel sheet to help create the name which is an area I am running into trouble with. Before I just had a hidden tab that compiled all the information I needed to create the correct name for the document. Now I need to figure out how to combine these things in VBA which is one of my big issues.

functioning delete auto lookups
Sub DeleteAutoLookUps()
'
' DeleteAutoLookUps Macro
'
' Keyboard Shortcut: Ctrl+Shift+Q
'
Range("A1:M73").Select
Selection.Copy
ActiveWindow.SmallScroll Down:=-33
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=-15
Sheets("coding").Select
ActiveWindow.SelectedSheets.Visible = False
Sheets("Vendors").Select
ActiveWindow.SelectedSheets.Visible = False
Sheets("Paste Here").Select
ActiveWindow.SelectedSheets.Visible = False
Range("Q11").Select

'Save as function per stack overflow


Application.ScreenUpdating = False


'Exit if U2 is empty


If ActiveSheet.Range("U2").Value = vbNullString Then Exit Sub


ThisFile = ActiveSheet.Range("U2").Value


ActiveWorkbook.SaveAs "L:\data\Marketing\Z Shared Outside Files\Retail Store Displays\Chelsea\Waiting to be placed\" & ThisFile, FileFormat:=xlOpenXMLWorkbook
Application.ScreenUpdating = True
ActiveWorkbook.Close
End Sub

<tbody>
</tbody>


email Code/what I have so far - red part is wrong but I don't know how to make it right. Light blue I changed but I am not sure the change is right.
Sub EMAIL()


Dim OAPPS As Object
Dim OMAIL As Object
Dim LWORKBOOK As Workbook
Dim LFILENAME As String


Application.ScreenUpdating = False


ActiveSheet.Copy
Set LWORKBOOK = ActiveWorkbook


LFILENAME = AND (ActiveSheet.Range("C14")),("-WHSE130-Display Order CMM-"),(ActiveSheet.Range("O4")),("ActiveSheet.Range("C14"))


On Error Resume Next


Kill LFILENAME
On Error GoTo 0


LWORKBOOK.SaveAs Filename:=LFILENAME


Set OAPP = CreateObject("OUTLOOK.APPLICATION")
Set OMAIL = OAPP.CREATEITEM(0)


With OMAIL
.To = "chelsea@abcdef.com"
.Subject = LWORKBOOK.FullName
.ATTACHMENTS.Add LWORKBOOK.FullName
.DISPLAY
End With


LWORKBOOK.ChangeFileAccess Mode:=xlOpenXMLWorkbook
Kill LWORKBOOK.FullName
LWORKBOOK.Close SAVECHANGES:=False


Application.ScreenUpdating = True
Set OMAIL = Nothing
Set OAPP = Nothing


End Sub

<tbody>
</tbody>
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,216,110
Messages
6,128,894
Members
449,477
Latest member
panjongshing

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