Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Run-time error €˜1004

I have the following macro in a workbook and a user keeps getting the same
runtime error that I cannot duplicate.

MACRO CODE---------------------------------
Sub Quote_Wrapup()
'To stop screen flicker
Application.ScreenUpdating = False

Range("quote_date").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("qdata5,qdata6").Font.ColorIndex = 2

'To delete delivery address lines if 1st line empty
If IsEmpty(Range("deliver_line1")) _
Then Sheets(1).Range("deliver_rows").EntireRow.Delete
'No End If required as only one action as a result of the If

Range("Item_Nos").SpecialCells(xlCellTypeBlanks).E ntireRow.Delete

Call paste_values

Sub paste_values()
With Sheet1.Range("A:F")
.Copy
.PasteSpecial xlPasteValues
End With
Application.CutCopyMode = False
End Sub
------------------------------------------------------
The user gets

Run-time error €˜1004
The information cannot be pasted because the copy area and the paste area
are not the same size and shape.

and the when debugged the following line is highlighted.
.................................................. .......................
.PasteSpecial xlPasteValues
.................................................. .......................

As the copy range is ("A:F") .i.e. columns I don't understand how this can
happen.

Grateful for any advice on this puzzle.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Run-time error €˜1004

I do not see anything that should generate that error. As a guess there is
more to this such as conversion to XL2007 or such. That being said to convert
to values can be done in a single line something like this...

Sheet1.Range("A:F").Value = Sheet1.Range("A:F").Value

No copy and paste or such...
--
HTH...

Jim Thomlinson


"Code Numpty" wrote:

I have the following macro in a workbook and a user keeps getting the same
runtime error that I cannot duplicate.

MACRO CODE---------------------------------
Sub Quote_Wrapup()
'To stop screen flicker
Application.ScreenUpdating = False

Range("quote_date").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("qdata5,qdata6").Font.ColorIndex = 2

'To delete delivery address lines if 1st line empty
If IsEmpty(Range("deliver_line1")) _
Then Sheets(1).Range("deliver_rows").EntireRow.Delete
'No End If required as only one action as a result of the If

Range("Item_Nos").SpecialCells(xlCellTypeBlanks).E ntireRow.Delete

Call paste_values

Sub paste_values()
With Sheet1.Range("A:F")
.Copy
.PasteSpecial xlPasteValues
End With
Application.CutCopyMode = False
End Sub
------------------------------------------------------
The user gets

Run-time error €˜1004
The information cannot be pasted because the copy area and the paste area
are not the same size and shape.

and the when debugged the following line is highlighted.
.................................................. ......................
.PasteSpecial xlPasteValues
.................................................. ......................

As the copy range is ("A:F") .i.e. columns I don't understand how this can
happen.

Grateful for any advice on this puzzle.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Run-time error €˜1004

The may be a problem with sheet1 rreference in this line

With Sheet1.Range("A:F")

Sheet1 is always defined. shouuld use

With Sheets(1).Range("A:F")

or better

With Sheets("sheet1").Range("A:F")

"Code Numpty" wrote:

I have the following macro in a workbook and a user keeps getting the same
runtime error that I cannot duplicate.

MACRO CODE---------------------------------
Sub Quote_Wrapup()
'To stop screen flicker
Application.ScreenUpdating = False

Range("quote_date").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("qdata5,qdata6").Font.ColorIndex = 2

'To delete delivery address lines if 1st line empty
If IsEmpty(Range("deliver_line1")) _
Then Sheets(1).Range("deliver_rows").EntireRow.Delete
'No End If required as only one action as a result of the If

Range("Item_Nos").SpecialCells(xlCellTypeBlanks).E ntireRow.Delete

Call paste_values

Sub paste_values()
With Sheet1.Range("A:F")
.Copy
.PasteSpecial xlPasteValues
End With
Application.CutCopyMode = False
End Sub
------------------------------------------------------
The user gets

Run-time error €˜1004
The information cannot be pasted because the copy area and the paste area
are not the same size and shape.

and the when debugged the following line is highlighted.
.................................................. ......................
.PasteSpecial xlPasteValues
.................................................. ......................

As the copy range is ("A:F") .i.e. columns I don't understand how this can
happen.

Grateful for any advice on this puzzle.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Run-time error €˜1004

Why should they use

With Sheets(1).Range("A:F")

if Sheet1 is the codename for the sheet?

That doesn't make sense to me.

Barb Reinhardt



"Joel" wrote:

The may be a problem with sheet1 rreference in this line

With Sheet1.Range("A:F")

Sheet1 is always defined. shouuld use

With Sheets(1).Range("A:F")

or better

With Sheets("sheet1").Range("A:F")

"Code Numpty" wrote:

I have the following macro in a workbook and a user keeps getting the same
runtime error that I cannot duplicate.

MACRO CODE---------------------------------
Sub Quote_Wrapup()
'To stop screen flicker
Application.ScreenUpdating = False

Range("quote_date").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("qdata5,qdata6").Font.ColorIndex = 2

'To delete delivery address lines if 1st line empty
If IsEmpty(Range("deliver_line1")) _
Then Sheets(1).Range("deliver_rows").EntireRow.Delete
'No End If required as only one action as a result of the If

Range("Item_Nos").SpecialCells(xlCellTypeBlanks).E ntireRow.Delete

Call paste_values

Sub paste_values()
With Sheet1.Range("A:F")
.Copy
.PasteSpecial xlPasteValues
End With
Application.CutCopyMode = False
End Sub
------------------------------------------------------
The user gets

Run-time error €˜1004
The information cannot be pasted because the copy area and the paste area
are not the same size and shape.

and the when debugged the following line is highlighted.
.................................................. ......................
.PasteSpecial xlPasteValues
.................................................. ......................

As the copy range is ("A:F") .i.e. columns I don't understand how this can
happen.

Grateful for any advice on this puzzle.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Run-time error €˜1004

Barb: If you delete Sheet one you no longer have a sheet1 codename. And if
you rename sheet2 sheet1 then sheet1 has a code name sheet2.

"Barb Reinhardt" wrote:

Why should they use

With Sheets(1).Range("A:F")

if Sheet1 is the codename for the sheet?

That doesn't make sense to me.

Barb Reinhardt



"Joel" wrote:

The may be a problem with sheet1 rreference in this line

With Sheet1.Range("A:F")

Sheet1 is always defined. shouuld use

With Sheets(1).Range("A:F")

or better

With Sheets("sheet1").Range("A:F")

"Code Numpty" wrote:

I have the following macro in a workbook and a user keeps getting the same
runtime error that I cannot duplicate.

MACRO CODE---------------------------------
Sub Quote_Wrapup()
'To stop screen flicker
Application.ScreenUpdating = False

Range("quote_date").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("qdata5,qdata6").Font.ColorIndex = 2

'To delete delivery address lines if 1st line empty
If IsEmpty(Range("deliver_line1")) _
Then Sheets(1).Range("deliver_rows").EntireRow.Delete
'No End If required as only one action as a result of the If

Range("Item_Nos").SpecialCells(xlCellTypeBlanks).E ntireRow.Delete

Call paste_values

Sub paste_values()
With Sheet1.Range("A:F")
.Copy
.PasteSpecial xlPasteValues
End With
Application.CutCopyMode = False
End Sub
------------------------------------------------------
The user gets

Run-time error €˜1004
The information cannot be pasted because the copy area and the paste area
are not the same size and shape.

and the when debugged the following line is highlighted.
.................................................. ......................
.PasteSpecial xlPasteValues
.................................................. ......................

As the copy range is ("A:F") .i.e. columns I don't understand how this can
happen.

Grateful for any advice on this puzzle.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Run-time error €˜1004

I too am not following you... If Sheet1 does not exist then you get a 424
Object Required error (or a compile error if you are using option explicit).

Sheets(1) is about the worst code you can use as there are any number of
things that can change the index numbers of the sheets, so there is no
reliable way of knowing which sheet is at index number 1.

Sheets("Sheet1") is also not great code as it is vulnerable to end user
changes to the tab name...

The most reliable code uses the code name of the sheet to get a direct
handle to the object...

What do you mean by "Sheet1 is always defined". If I delete the sheet with
code name Sheet1, then it is not defined. The object is gone.

It is definitely advisable to change the code names of the sheets. If I
delete Sheet1 it is gone. But if I close the book and reopen it and add a new
sheet it will be a new sheet with code name Sheet1... By changing the code
name to something like shtMySheet I get around that potential problem and end
up with foolproof code.
--
HTH...

Jim Thomlinson


"Joel" wrote:

Barb: If you delete Sheet one you no longer have a sheet1 codename. And if
you rename sheet2 sheet1 then sheet1 has a code name sheet2.

"Barb Reinhardt" wrote:

Why should they use

With Sheets(1).Range("A:F")

if Sheet1 is the codename for the sheet?

That doesn't make sense to me.

Barb Reinhardt



"Joel" wrote:

The may be a problem with sheet1 rreference in this line

With Sheet1.Range("A:F")

Sheet1 is always defined. shouuld use

With Sheets(1).Range("A:F")

or better

With Sheets("sheet1").Range("A:F")

"Code Numpty" wrote:

I have the following macro in a workbook and a user keeps getting the same
runtime error that I cannot duplicate.

MACRO CODE---------------------------------
Sub Quote_Wrapup()
'To stop screen flicker
Application.ScreenUpdating = False

Range("quote_date").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("qdata5,qdata6").Font.ColorIndex = 2

'To delete delivery address lines if 1st line empty
If IsEmpty(Range("deliver_line1")) _
Then Sheets(1).Range("deliver_rows").EntireRow.Delete
'No End If required as only one action as a result of the If

Range("Item_Nos").SpecialCells(xlCellTypeBlanks).E ntireRow.Delete

Call paste_values

Sub paste_values()
With Sheet1.Range("A:F")
.Copy
.PasteSpecial xlPasteValues
End With
Application.CutCopyMode = False
End Sub
------------------------------------------------------
The user gets

Run-time error €˜1004
The information cannot be pasted because the copy area and the paste area
are not the same size and shape.

and the when debugged the following line is highlighted.
.................................................. ......................
.PasteSpecial xlPasteValues
.................................................. ......................

As the copy range is ("A:F") .i.e. columns I don't understand how this can
happen.

Grateful for any advice on this puzzle.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Run-time error €˜1004

It is only fool proof if somebody doesn't delete the sheet. I like to have
the sheet names visible so I can easily see the problem and fix the problem
when sheets are re-named, moved, or deleted.

"Jim Thomlinson" wrote:

I too am not following you... If Sheet1 does not exist then you get a 424
Object Required error (or a compile error if you are using option explicit).

Sheets(1) is about the worst code you can use as there are any number of
things that can change the index numbers of the sheets, so there is no
reliable way of knowing which sheet is at index number 1.

Sheets("Sheet1") is also not great code as it is vulnerable to end user
changes to the tab name...

The most reliable code uses the code name of the sheet to get a direct
handle to the object...

What do you mean by "Sheet1 is always defined". If I delete the sheet with
code name Sheet1, then it is not defined. The object is gone.

It is definitely advisable to change the code names of the sheets. If I
delete Sheet1 it is gone. But if I close the book and reopen it and add a new
sheet it will be a new sheet with code name Sheet1... By changing the code
name to something like shtMySheet I get around that potential problem and end
up with foolproof code.
--
HTH...

Jim Thomlinson


"Joel" wrote:

Barb: If you delete Sheet one you no longer have a sheet1 codename. And if
you rename sheet2 sheet1 then sheet1 has a code name sheet2.

"Barb Reinhardt" wrote:

Why should they use

With Sheets(1).Range("A:F")

if Sheet1 is the codename for the sheet?

That doesn't make sense to me.

Barb Reinhardt



"Joel" wrote:

The may be a problem with sheet1 rreference in this line

With Sheet1.Range("A:F")

Sheet1 is always defined. shouuld use

With Sheets(1).Range("A:F")

or better

With Sheets("sheet1").Range("A:F")

"Code Numpty" wrote:

I have the following macro in a workbook and a user keeps getting the same
runtime error that I cannot duplicate.

MACRO CODE---------------------------------
Sub Quote_Wrapup()
'To stop screen flicker
Application.ScreenUpdating = False

Range("quote_date").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("qdata5,qdata6").Font.ColorIndex = 2

'To delete delivery address lines if 1st line empty
If IsEmpty(Range("deliver_line1")) _
Then Sheets(1).Range("deliver_rows").EntireRow.Delete
'No End If required as only one action as a result of the If

Range("Item_Nos").SpecialCells(xlCellTypeBlanks).E ntireRow.Delete

Call paste_values

Sub paste_values()
With Sheet1.Range("A:F")
.Copy
.PasteSpecial xlPasteValues
End With
Application.CutCopyMode = False
End Sub
------------------------------------------------------
The user gets

Run-time error €˜1004
The information cannot be pasted because the copy area and the paste area
are not the same size and shape.

and the when debugged the following line is highlighted.
.................................................. ......................
.PasteSpecial xlPasteValues
.................................................. ......................

As the copy range is ("A:F") .i.e. columns I don't understand how this can
happen.

Grateful for any advice on this puzzle.

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
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Error handling error # 1004 Run-time error [email protected] Excel Programming 3 May 20th 08 02:23 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) Tim[_36_] Excel Programming 4 April 23rd 04 02:53 AM


All times are GMT +1. The time now is 05:47 PM.

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

About Us

"It's about Microsoft Excel"