Why R/T error 1004 - 7 rows from the end of this code

J

JMay

Private Sub Workbook_Open()
ans = MsgBox("Would you like to CLEAR the WorkingReport Sheet at this
time?", vbYesNo)
If ans = vbNo Then
MsgBox "The WorkingReport has not been updated, be CAREFUL!!"
Exit Sub
Else
Worksheets("WorkingReport").Cells.ClearContents
Worksheets("WorkingReport").Range("Z1").Copy 'copies an
unformatted cell
Worksheets("WorkingReport").Range("A1:Q300").PasteSpecial
Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
With Worksheets("WorkingReport")
.Range("A1").Select ' WHY R/T 1004 Here????????????
End With
Application.CutCopyMode = False
Worksheets("Start Here").Activate
Range("C4").Select
End If
End Sub
 
J

JLGWhiz

The sheet must first be activated.

With Worksheets('WorkingReport")
.Activate
.Range("A1").Select
End With

It is better to use a coding style that eliminates Activate and Select as
much as possible, which is almost completely.
 
D

Dave Peterson

Another way:

application.goto Worksheets("WorkingReport").Range("A1"), scroll:=true '???
 
J

JMay

Thanks JLGWhiz,

Rule#1 (somehow missed):
If you use the SELECT method you must be ALREADY BE INSIDE the sheet
of the Range you wish to SELECT.

Is there a list of the other 6 DEADLIEST Sins (Rules) that I can MEMORIZE?

Thanks,

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top