Hi
Elaborating on Mike's and Sam's posts, make sure all the Sheet names and range names used exist, that is the most likely course, and you don't need quotes in the VLOOKUP formula Contracts is a range name
Code:
Sub BuildData()
Dim DataMaxRow As Long
DataMaxRow = ThisWorkbook.Sheets("Lookup").Range("DataMaxRow").Value + 2
With ThisWorkbook.Sheets("AgedAccounts")
.Range("B6", .Range("B" & DataMaxRow)).Formula = "=VLOOKUP(C6,Contracts,2,0)"
.Range("G6", .Range("G" & DataMaxRow)).Formula = "=MONTH(F6)"
.Range("A5", .Range("H" & DataMaxRow)).Copy
.Range("A5").PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End With
End Sub
As Shades indicated I have removes CStr() as integers concatenate into string without problems in
VB and VBA without problems, but I think you would need CStr() in .NET ? and other languages.
I have also removed ThisWorkbook.Sheets("AgedAccounts") inside the With block otherwise there is no point in using With !
This code runs but obviously it does not make sense as I do not have you data structure.
HTH
MTB