Hi there,
See if the following code does what you need:
Option Explicit
Sub CreateWorkbook()
Const sCOLUMN_DATES As String = "B"
Const sCOLUMN_NAME As String = "A"
Const sFILE_SUFFIX As String = ".xlsx"
Const sSHEET_NAME As String = "Sheet1"
Dim dteLatestDate As Date
Dim sLatestDate As String
Dim rDateCells As Range
Dim sCustomer As String
Dim sFileName As String
Dim wks As Worksheet
Set wks = ThisWorkbook.Worksheets(sSHEET_NAME)
With wks
sCustomer = .Columns(sCOLUMN_NAME).Cells(1, 1).Value
Set rDateCells = Intersect(.UsedRange, _
.Columns(sCOLUMN_DATES))
dteLatestDate = WorksheetFunction.Max(rDateCells)
sLatestDate = Format(dteLatestDate, "yyyy.mm.dd")
sFileName = sLatestDate & "_" & sCustomer & "_Giving Statement" & sFILE_SUFFIX
wks.Copy
ActiveWorkbook.SaveAs Filename:=sFileName
End With
End Sub
The highlighted values may be altered to suit your requirements.
Hope this helps - please let me know how you get on.
Regards,
Greg M
Bookmarks