Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default Problem with Range Object

I sometimes get an error with this code. The error says:

"Run-time error '1004':

THe command could not be completed by using the range specified. Select a
single cell within the range and try the command again."

The object is not empty, and it has a valid range. What does this error
mean, and why does it not happen every time?

Code:

Dim typeCol As Integer, typeRng As Range

' Reset these values to fit the correct columns
typeCol = 8
lastRow = Cells(65536, 1).End(xlUp).Row

' Define Ranges
Set typeRng = Range(Cells(2, typeCol), Cells(lastRow, typeCol))

' Create unique list of used types
typeRng.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"I2"), Unique:=True
Range("I2").Select

Thanks,
Pflugs
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Problem with Range Object

It would be helpful if you would specify which line of code throws the
error.

Just a guess, but have you tried to use a fully qualified range (i.e.,
including the worksheet reference)?
__________________________________________________ _____________________


"Pflugs" wrote in message
...
I sometimes get an error with this code. The error says:

"Run-time error '1004':

THe command could not be completed by using the range specified. Select a
single cell within the range and try the command again."

The object is not empty, and it has a valid range. What does this error
mean, and why does it not happen every time?

Code:

Dim typeCol As Integer, typeRng As Range

' Reset these values to fit the correct columns
typeCol = 8
lastRow = Cells(65536, 1).End(xlUp).Row

' Define Ranges
Set typeRng = Range(Cells(2, typeCol), Cells(lastRow, typeCol))

' Create unique list of used types
typeRng.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"I2"), Unique:=True
Range("I2").Select

Thanks,
Pflugs



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default Problem with Range Object

Yes, adding the sheet reference to the declaration seems to help. The macro
was failing as I tried to apply the Advanced Filter.

Thanks!
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
Problem is using any method of Range Object Shilps[_2_] Excel Programming 3 October 29th 04 06:24 AM
problem using Set statement to define range object mel Excel Programming 0 February 4th 04 06:10 PM
Range object to Array object conversion Myrna Larson[_2_] Excel Programming 1 August 1st 03 02:27 AM
Range object to Array object conversion Alan Beban[_3_] Excel Programming 0 August 1st 03 01:24 AM
Range object to Array object conversion Tom Ogilvy Excel Programming 0 August 1st 03 12:16 AM


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