Dear Team,
I want to include my cell value (Worksheets("Training") "B4") on outlook mail attachment file name. For that i am writing the following code
Code
Dim wks As Worksheet
Dim myDate As String
For Each wks In ThisWorkbook.Worksheets
If InStr(wks.Name, "DP") > 0 Then
wks.Visible = xlSheetVisible
End If
Next wks
Worksheets("DP").Copy
Set WB = ActiveWorkbook
myDate = Worksheets("Training").Cell(4, "B").Value
FileName = " Training details of " & myDate & ".xlsx"
On Error Resume Next
'Kill "D:\" & FileName
On Error GoTo 0
WB.SaveAs FileName:="D:\" & FileName
For Each wks In ThisWorkbook.Worksheets
If InStr(wks.Name, "DP") > 0 Then
'wks.Visible = xlSheetVeryHidden
End If
Next wks
Display More
But i am getting error message.
Anyone please correct the code