-
[VBA]
Sub CreateAdminTimeCards()
Dim cel As Range, WB As Workbook, Pth As String
Dim fs, SubPth As String
Set fs = CreateObject("Scripting.FileSystemObject")
Pth = "C:\2010 Timecards\"
Application.ScreenUpdating = False
SubPth = ActiveWorkbook.Path & "\" & cel.Offset(, 2)
If Not fs.folderexists(SubPth) Then MkDir SubPth
For Each cel In Selection
Set WB = Workbooks.Open(Pth & "2010 Admin.xls")
With WB
.Sheets("TS1").Cells(3, 1) = cel
.Sheets("TS1").Cells(4, 1) = cel.Offset(, 1)
.Sheets("TS1").Cells(3, 9) = cel.Offset(, 2)
.SaveAs (SubPth & "\" & cel & ".xls")
.Close
End With
Application.ScreenUpdating = True
Next
End Sub
[/VBA]
-
When i run this I get
Run-time error '91':
Object variable or With block variable not set
when i hit debug it highlights this line
Code:
SubPth = ActiveWorkbook.Path & "\" & cel.Offset(, 2)
-
Can anyone help with the error i get with this code??
Its so close to doing what i want I hate to give up now...
Thanks