Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default Why R/T error 1004 - 7 rows from the end of this code

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").Paste Special
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Why R/T error 1004 - 7 rows from the end of this code

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.

"JMay" wrote:

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").Paste Special
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Why R/T error 1004 - 7 rows from the end of this code

Another way:

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


JMay wrote:

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").Paste Special
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


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default Why R/T error 1004 - 7 rows from the end of this code

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

"JLGWhiz" wrote:

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.

"JMay" wrote:

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").Paste Special
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
runtime error code 1004 Karen Excel Worksheet Functions 1 May 13th 10 12:21 AM
runtime error 1004: how can i use rows. milkar miao[_2_] Excel Programming 1 October 20th 07 01:57 PM
Code Run-time error '1004' pjhageman[_5_] Excel Programming 3 January 11th 04 12:24 AM
VBA code to save gives error 1004??? Richard m Excel Programming 1 November 26th 03 04:10 AM


All times are GMT +1. The time now is 11:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"