Hi All,
I am trying to write a mcaro to create a vlaues only version of my active workbook. So in words the steps are (assuming the desired workbook is already open and active):I tried to start Steps 3, 4 and 5, but even they seem to fall apart at each for loops with "Runtime erros 13 - debug mismatch". The program I wriote is as follows:
- Create a copy of the Active workbook - call it say newvaluesworkbook in VBA.
- In newvaluesworkbook. select all worksheets and globally value paste over their existing cells - thus making it values only.
- All cells in newvaluesworkbook should have no highlighting i.e. Colorindex = Xlnone.
- Set all tab colours in newvaluesworkbook to have "No Colour"
- Delete all comments in newvaluesworkbook.
- Save newvaluesworkbook with the same name as the Active workbook but append with "_values only". E.g. if active workbook is SpreadsheetD.xls, then newvaluesworkbook should be named as SpreadsheetD_values only.xls
- Save the newvaluesworkbook workbook in the same directory as the activeworkbook, but in the Values folder. E.g If we have C:\SpreadsheetD.xls, then we want to create C:\Values\SpreadsheetD.xls. The values folder will exist for the active workbooks selected.
[vba]Sub create_Values_only_workbook()
Dim wbkwkshts As Worksheets
Dim wbkcomment As Comments
Application.ScreenUpdating = False
For Each wbkcomment In ThisWorkbook.Worksheets
wbkcomment.Delete
Next
For Each wbkwkshts In ThisWorkbook.Worksheets
wbkwkshts.Cells.Select
Selection.Interior.ColorIndex = xlNone
wbkwkshts.Tab.ColorIndex = -4142
Next
Application.ScreenUpdating = True
End Sub[/vba]
If anyone could please anyone please guide me in writing the above, I would really appreciate it.