Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Range error question

Status
Not open for further replies.

rarogersonkf

Programmer
Aug 23, 2005
23
CA
Can someone explain why I get an run time error on the range statement please.
I'm creting a new sheet, naming it with the selection date
and beginning to format the cells.
The cells statements work fine but the range ends with an error.

Set NewSheet = Sheets.Add
NewSheet.Name = CStr(SelectDateNum)

Sheets(CStr(SelectDateNum)).Activate
Cells.ClearContents
Cells.ClearFormats

Range("A1").Activate

Any help is greatly appreciated.

Rob
 
I get an run time error
Any chance you could post the whole error message ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
What is the error message?

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
Sorry, a message would help...

Run-time error '1004'

Application-defined or object-defined error.

Thanks again,

Rob
 
You need to specify the sheet - try this:

Set NewSheet = Sheets.Add
NewSheet.Name = CStr(SelectDateNum)

with NewSheet
.activate
.Cells.ClearContents
.Cells.ClearFormats
.Range("A1").Activate
end with


Rgds, Geoff

Three things are certain. Death, taxes and lost data. DPlank is to blame

Please read FAQ222-2244 before you ask a question
 
As the sheet is just created why this ?
Cells.ClearContents

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top