richarddhill
New Member
- Joined
- Jul 16, 2008
- Messages
- 11
Hi all you peoiple with real skills,
I want to name a worksheet with todays date and have tried the following code only to get an error message saying "Object variable or With Block Variable not set". I am using Excel 2007
Dim WS As Worksheet
Sheets("Goods Received").Select
'and select the cells and copy them
Cells.Select
Selection.Copy
'then add a new worksheet
Sheets.Add After:=Sheets(Sheets.Count)
'and paste the values of the cell into here
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'then select cell A1 and make the cell value todays date
Range("A1").Select
ActiveCell.FormulaR1C1 = "=TODAY()"
WS.Name = WS.Range("A1").Text
Can anyone suggest an alternative that works? I would be most grateful.
Regards,
Richard
I want to name a worksheet with todays date and have tried the following code only to get an error message saying "Object variable or With Block Variable not set". I am using Excel 2007
Dim WS As Worksheet
Sheets("Goods Received").Select
'and select the cells and copy them
Cells.Select
Selection.Copy
'then add a new worksheet
Sheets.Add After:=Sheets(Sheets.Count)
'and paste the values of the cell into here
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'then select cell A1 and make the cell value todays date
Range("A1").Select
ActiveCell.FormulaR1C1 = "=TODAY()"
WS.Name = WS.Range("A1").Text
Can anyone suggest an alternative that works? I would be most grateful.
Regards,
Richard