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

It is an application or object defined error. The first line works but the
second one gives the error in my sort macro. I'm trying to use the count to
left for the columns because the users keep adding columns. Do I have a
missing parenthesis? It seems like both lines are the same.
Thanks,
Set Rng = .Range(.Cells(2, 1), _
..Cells(Rows.Count, .Cells(1, Columns.Count).End(xlToLeft)).End(xlUp))
'Set Rng = .Range(.Cells(2, 1), .Cells(Rows.Count, 26).End(xlUp))

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 477
Default runtime 1004 error

I don't recall seeing (IN YOUR 2nd LINE) ... both (xlToLeft)).End(xlUp))
Maybe Excel is getting confused...
FWIW...
Jim

"Janis" wrote:

It is an application or object defined error. The first line works but the
second one gives the error in my sort macro. I'm trying to use the count to
left for the columns because the users keep adding columns. Do I have a
missing parenthesis? It seems like both lines are the same.
Thanks,
Set Rng = .Range(.Cells(2, 1), _
.Cells(Rows.Count, .Cells(1, Columns.Count).End(xlToLeft)).End(xlUp))
'Set Rng = .Range(.Cells(2, 1), .Cells(Rows.Count, 26).End(xlUp))

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default runtime 1004 error

What does your with clause look like. Both of these statements are meant to
be within the bounds of a with statement.

..Cells or .Range must have a sheet specified from a with statement. If you
do not have that with statement then this would bomb...
--
HTH...

Jim Thomlinson


"Janis" wrote:

It is an application or object defined error. The first line works but the
second one gives the error in my sort macro. I'm trying to use the count to
left for the columns because the users keep adding columns. Do I have a
missing parenthesis? It seems like both lines are the same.
Thanks,
Set Rng = .Range(.Cells(2, 1), _
.Cells(Rows.Count, .Cells(1, Columns.Count).End(xlToLeft)).End(xlUp))
'Set Rng = .Range(.Cells(2, 1), .Cells(Rows.Count, 26).End(xlUp))

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default runtime 1004 error

Sorry... My Bad 9since I gave you that code in the first place... Try this

Set rng = _
..Range(.Cells(2, 1), .Cells(Rows.Count, .Cells(1,
Columns.Count).End(xlToLeft).Column).End(xlUp))

Note the .Column
--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

What does your with clause look like. Both of these statements are meant to
be within the bounds of a with statement.

.Cells or .Range must have a sheet specified from a with statement. If you
do not have that with statement then this would bomb...
--
HTH...

Jim Thomlinson


"Janis" wrote:

It is an application or object defined error. The first line works but the
second one gives the error in my sort macro. I'm trying to use the count to
left for the columns because the users keep adding columns. Do I have a
missing parenthesis? It seems like both lines are the same.
Thanks,
Set Rng = .Range(.Cells(2, 1), _
.Cells(Rows.Count, .Cells(1, Columns.Count).End(xlToLeft)).End(xlUp))
'Set Rng = .Range(.Cells(2, 1), .Cells(Rows.Count, 26).End(xlUp))

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 1004 JB Bates[_2_] Excel Discussion (Misc queries) 5 December 29th 09 02:40 PM
Runtime error 1004 Zippy Excel Programming 3 March 2nd 06 08:39 PM
Runtime error 1004 Terry K Excel Programming 2 September 7th 05 09:57 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Runtime error 1004 Jeannette[_2_] Excel Programming 0 May 13th 04 06:31 AM


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