Hello All,
I am using the following to create a workbook. The string derived from Now() will be used as part of the name of the workbook
Thus I never get two workbooks with the same name.
Q1: Sometimes Right(Left(RC[-2],9),4) replaces a zero with a decimal. It works fine in the environments where I have used it, but I thought a decimal was an illegal character for naming a workbook... I get something like: "406538.3.xls" should I take steps to eliminate this?
Q2. Does the variable nowCell survive after I name the workbook in the same procedure?
Thank you.
I am using the following to create a workbook. The string derived from Now() will be used as part of the name of the workbook
Code:
Workbooks.Add
With ActiveWorkbook.Worksheets("Sheet1").Range("E1")
.FormulaR1C1 = "=NOW()"
.NumberFormat = "0.000"
End With
Dim nowCell As Range
Set nowCell = ActiveWorkbook.Worksheets("Sheet1").Range("B1")
nowCell.Value = Range("E1").Value
nowCell.Offset(0, 1).Formula = "=LEFT(RC[-1],5)"
nowCell.Offset(0, 2).Formula = "=Right(Left(RC[-2],9),4)"
leftStr = nowCell.Offset(0,1).Value
rightStr = nowCell.Offset(0,2).Value
ActiveWorkbook.SaveAs thisBook.Path & "/" & leftStr & rightStr
& ".xls"
Q1: Sometimes Right(Left(RC[-2],9),4) replaces a zero with a decimal. It works fine in the environments where I have used it, but I thought a decimal was an illegal character for naming a workbook... I get something like: "406538.3.xls" should I take steps to eliminate this?
Q2. Does the variable nowCell survive after I name the workbook in the same procedure?
Thank you.