Macro creates additional datafiles when saving copies of workbook
Hi Peter,
Immediately before the line:
ActiveWorkbook.SaveAs Filename:=TestFolderName ...
paste the diagnostic code:
With testdatacell
MsgBox "testdatacell address = " & .Address(0, 0, , 1) _
& vbTab & "Value = " & .Value
End With
Then see if testdatacell is what you expect it to be in terms of location
and value.
---
Regards,
Norman
"Peter Rooney" wrote in message
...
Good morning, all!
I am using a simple loop to create test data workbooks. There is a 5X1
range
"DropDownTeams" which is referred to as "TestDataCell" - the cells contain
ELS1, ELS2...ELS5.
My macro successfully creates the following workbooks:
D:\Pete's Operations\Personal\Test\SOFT Report - 0530 - ELS1.xls
D:\Pete's Operations\Personal\Test\SOFT Report - 0530 - ELS2.xls
D:\Pete's Operations\Personal\Test\SOFT Report - 0530 - ELS3.xls
D:\Pete's Operations\Personal\Test\SOFT Report - 0530 - ELS4.xls
D:\Pete's Operations\Personal\Test\SOFT Report - 0530 - ELS5.xls
the "0530" being the contents of two additional variables generated by the
macro YearWeekResourceName. However, I ALSO get five additional files
created, the same size as the original workbook, with no file extension
and a
filename made up of 8 random alphanumeric characters.
Can anyone suggest why these files are being created? Are they temp files,
and, if this is the case, why aren't they being deleted?
Thanks in advance
Pete
Sub SetTestFolderName()
TestFolderName = "D:\Pete's operations\Personal\Test\"
End Sub
Sub TestDataTeam()
For Each TestDataCell In Sheets("DropDownLists").Range("DropDownTeams")
Sheets("Database").Range("HeaderRemarks").Offset(1 , 0).Value =
TestDataCell.Value
Sheets("Database").Range("HeaderSubTeam").Offset(1 , 0).Value = ""
SaveTestData
Next
End Sub
Sub SaveTestData()
SetTestFolderName
DefineDatabase
YearWeekResourceName
'Application.DisplayAlerts = False
& Year & "-" & WeekNumber
& _
" - SOFT Report - " & TestDataCell.Value & ".xls", _
FileFormat:=xlExcel9795, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub
|