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

I can run this from any sheet and it works
sheets("Sheet1").Range("A1:A5").Copy sheets("Sheet2").Range("A1")

So why will this run from sheet 1 but when I run it from another sheet I get
a run time error 1004? And how can this be fixed?
sheets("Sheet1").Range(Range("A1"), Range("B1").End(xlDown)).Copy
sheets("Sheet2").Range("A1")

Thanks



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Run time error 1004

word wrap got it should all be on one line or this
sheets("Sheet1").Range(Range("A1"), Range("B1").End(xlDown)).Copy _
sheets("Sheet2").Range("A1")



"Paul B" wrote in message
...
I can run this from any sheet and it works
sheets("Sheet1").Range("A1:A5").Copy sheets("Sheet2").Range("A1")

So why will this run from sheet 1 but when I run it from another sheet I

get
a run time error 1004? And how can this be fixed?
sheets("Sheet1").Range(Range("A1"), Range("B1").End(xlDown)).Copy
sheets("Sheet2").Range("A1")

Thanks





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Run time error 1004

You have some unqualified ranges in your statement. Unqualified ranges in
general modules point at the active sheet. But unqualified ranges in a
worksheet module point at that worksheet.

This portion:
sheets("Sheet1").Range(Range("A1"), Range("B1").End(xlDown)).Copy
could be rewritten as:

sheets("sheet1").range(sheets("sheet1").range("a1" ), _
sheets("sheet1").range("b1")).end(xldown).copy

Notice each Range has a qualified worksheet in front of it.

But to save your fingers:

With Worksheets("sheet1")
.Range(.Range("a1"), .Range("b1")).End(xlDown).Copy _
Destination:=Worksheets("sheet2").Range("a1")
End With

or even:

With Worksheets("sheet1")
.Range("a1:b1").End(xlDown).Copy _
Destination:=Worksheets("sheet2").Range("a1")
End With

(Just a curiosity, when I did this, it was pretty much the same as using A1 by
itself. Is that what you wanted?)

If you wanted A1:bottom of B, then maybe:

With Worksheets("sheet1")
.Range("a1", .Range("b1").End(xlDown)).Copy _
Destination:=Worksheets("sheet2").Range("a1")
End With


Paul B wrote:

I can run this from any sheet and it works
sheets("Sheet1").Range("A1:A5").Copy sheets("Sheet2").Range("A1")

So why will this run from sheet 1 but when I run it from another sheet I get
a run time error 1004? And how can this be fixed?
sheets("Sheet1").Range(Range("A1"), Range("B1").End(xlDown)).Copy
sheets("Sheet2").Range("A1")

Thanks


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Run time error 1004

Dave, thanks, yes I wanted A1:bottom of B, and it was working to do that,
but I see that it can be done in a better way, thanks again
"Dave Peterson" wrote in message
...
You have some unqualified ranges in your statement. Unqualified ranges in
general modules point at the active sheet. But unqualified ranges in a
worksheet module point at that worksheet.

This portion:
sheets("Sheet1").Range(Range("A1"), Range("B1").End(xlDown)).Copy
could be rewritten as:

sheets("sheet1").range(sheets("sheet1").range("a1" ), _
sheets("sheet1").range("b1")).end(xldown).copy

Notice each Range has a qualified worksheet in front of it.

But to save your fingers:

With Worksheets("sheet1")
.Range(.Range("a1"), .Range("b1")).End(xlDown).Copy _
Destination:=Worksheets("sheet2").Range("a1")
End With

or even:

With Worksheets("sheet1")
.Range("a1:b1").End(xlDown).Copy _
Destination:=Worksheets("sheet2").Range("a1")
End With

(Just a curiosity, when I did this, it was pretty much the same as using

A1 by
itself. Is that what you wanted?)

If you wanted A1:bottom of B, then maybe:

With Worksheets("sheet1")
.Range("a1", .Range("b1").End(xlDown)).Copy _
Destination:=Worksheets("sheet2").Range("a1")
End With


Paul B wrote:

I can run this from any sheet and it works
sheets("Sheet1").Range("A1:A5").Copy sheets("Sheet2").Range("A1")

So why will this run from sheet 1 but when I run it from another sheet I

get
a run time error 1004? And how can this be fixed?
sheets("Sheet1").Range(Range("A1"), Range("B1").End(xlDown)).Copy
sheets("Sheet2").Range("A1")

Thanks


--

Dave Peterson



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 Steph Excel Discussion (Misc queries) 1 May 4th 06 10:29 PM
Run time error 1004! steph00 Excel Discussion (Misc queries) 0 May 4th 06 04:45 PM
Run-Time error '1004' [email protected] Excel Discussion (Misc queries) 3 March 29th 06 08:13 PM
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
Run-Time error '1004' Bob[_33_] Excel Programming 2 August 28th 03 03:10 PM


All times are GMT +1. The time now is 03:15 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"