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

I copied some bode from a book that takes up about 3 pages that isn't working.

I get the following error message:

"Run-time error €˜1004;
Method €˜Range of object €˜_Worksheet failed"



When I click on debug the following line is highlighted:

"Set rgTopLeft = ws.Range(FOUND_LIST).Offset(1, 0)"

Any suggestions on how I can find out what needs to be changed in order to
make this work?

Regards,

Rob


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

Rob C,

It is probably in the variable FOUND_LIST. When you click on debug the
following and the line is highlighter hover over the FOUND_LIST with your
mouse. Probably it is returning EMPTY.

If this is the case you have to set the variable somewhere. For example:
FOUND_LIST = "A1", however this is depending on what you code should do and
which range have to be set in your code.


brotha lee
"rob c" wrote:

I copied some bode from a book that takes up about 3 pages that isn't working.

I get the following error message:

"Run-time error €˜1004;
Method €˜Range of object €˜_Worksheet failed"



When I click on debug the following line is highlighted:

"Set rgTopLeft = ws.Range(FOUND_LIST).Offset(1, 0)"

Any suggestions on how I can find out what needs to be changed in order to
make this work?

Regards,

Rob


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

Brotha,

Thanks for the assistance.

When I did the hover, it returned FOUND_LIST" =FoundList", so I gave a range
on the spreadsheet the name "FoundList". This removed the data from all the
fields in the range (I am trying to get certain data from the range to be
placed in a different column, but keep it in the cells it was already as
well) except for the first field and gave me a different error message,
"Compile error Sub or Function not defined". and highlighted "wscells" in
the function below:

' sets a range reference to the range containing
' the list = the product column
Private Function GetSearchRange(ws As Worksheet) As Range
Dim lLastRow As Long

lLastRow = ws.Cells(5000, 1).End(xlUp).Row
Set GetSearchRange = ws.Range(wsCells(1, 2), _
wsCells(lLastRow, 2))
End Function

Regards,

Rob


"Brotha Lee" wrote:

Rob C,

It is probably in the variable FOUND_LIST. When you click on debug the
following and the line is highlighter hover over the FOUND_LIST with your
mouse. Probably it is returning EMPTY.

If this is the case you have to set the variable somewhere. For example:
FOUND_LIST = "A1", however this is depending on what you code should do and
which range have to be set in your code.


brotha lee
"rob c" wrote:

I copied some bode from a book that takes up about 3 pages that isn't working.

I get the following error message:

"Run-time error €˜1004;
Method €˜Range of object €˜_Worksheet failed"



When I click on debug the following line is highlighted:

"Set rgTopLeft = ws.Range(FOUND_LIST).Offset(1, 0)"

Any suggestions on how I can find out what needs to be changed in order to
make this work?

Regards,

Rob


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


ws is the worksheet. To get at the cells property you need the dot so
ws.cells or better still.

' sets a range reference to the range containing
' the list = the product column
Private Function GetSearchRange(ws As Worksheet) As Range
Dim lLastRow As Long

with ws
lLastRow = .Cells(5000, 1).End(xlUp).Row
Set GetSearchRange = .Range(.Cells(1, 2), _
.Cells(lLastRow, 2))
end with
End Function

--
HTH...

Jim Thomlinson


"rob c" wrote:

Brotha,

Thanks for the assistance.

When I did the hover, it returned FOUND_LIST" =FoundList", so I gave a range
on the spreadsheet the name "FoundList". This removed the data from all the
fields in the range (I am trying to get certain data from the range to be
placed in a different column, but keep it in the cells it was already as
well) except for the first field and gave me a different error message,
"Compile error Sub or Function not defined". and highlighted "wscells" in
the function below:

' sets a range reference to the range containing
' the list = the product column
Private Function GetSearchRange(ws As Worksheet) As Range
Dim lLastRow As Long

lLastRow = ws.Cells(5000, 1).End(xlUp).Row
Set GetSearchRange = ws.Range(wsCells(1, 2), _
wsCells(lLastRow, 2))
End Function

Regards,

Rob


"Brotha Lee" wrote:

Rob C,

It is probably in the variable FOUND_LIST. When you click on debug the
following and the line is highlighter hover over the FOUND_LIST with your
mouse. Probably it is returning EMPTY.

If this is the case you have to set the variable somewhere. For example:
FOUND_LIST = "A1", however this is depending on what you code should do and
which range have to be set in your code.


brotha lee
"rob c" wrote:

I copied some bode from a book that takes up about 3 pages that isn't working.

I get the following error message:

"Run-time error €˜1004;
Method €˜Range of object €˜_Worksheet failed"



When I click on debug the following line is highlighted:

"Set rgTopLeft = ws.Range(FOUND_LIST).Offset(1, 0)"

Any suggestions on how I can find out what needs to be changed in order to
make this work?

Regards,

Rob


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

Jim,

Thanks for the advice, I'm going to try to keep the code as close to what it
was in the book as possible so I used the "ws.cells" suggestion.

Now I get a different error message, "Run-time error '1004';
Application-defined or object-defined error" The following is highlighed when
I click on debug (Else and End If are not highlighted but it shows the
context at litlte).


"
Else
Set rgDestination = rgDestination.End(xlDown).Offset(1, 0)

End If"


"Jim Thomlinson" wrote:

ws is the worksheet. To get at the cells property you need the dot so
ws.cells or better still.

' sets a range reference to the range containing
' the list = the product column
Private Function GetSearchRange(ws As Worksheet) As Range
Dim lLastRow As Long

with ws
lLastRow = .Cells(5000, 1).End(xlUp).Row
Set GetSearchRange = .Range(.Cells(1, 2), _
.Cells(lLastRow, 2))
end with
End Function

--
HTH...

Jim Thomlinson


"rob c" wrote:

Brotha,

Thanks for the assistance.

When I did the hover, it returned FOUND_LIST" =FoundList", so I gave a range
on the spreadsheet the name "FoundList". This removed the data from all the
fields in the range (I am trying to get certain data from the range to be
placed in a different column, but keep it in the cells it was already as
well) except for the first field and gave me a different error message,
"Compile error Sub or Function not defined". and highlighted "wscells" in
the function below:

' sets a range reference to the range containing
' the list = the product column
Private Function GetSearchRange(ws As Worksheet) As Range
Dim lLastRow As Long

lLastRow = ws.Cells(5000, 1).End(xlUp).Row
Set GetSearchRange = ws.Range(wsCells(1, 2), _
wsCells(lLastRow, 2))
End Function

Regards,

Rob


"Brotha Lee" wrote:

Rob C,

It is probably in the variable FOUND_LIST. When you click on debug the
following and the line is highlighter hover over the FOUND_LIST with your
mouse. Probably it is returning EMPTY.

If this is the case you have to set the variable somewhere. For example:
FOUND_LIST = "A1", however this is depending on what you code should do and
which range have to be set in your code.


brotha lee
"rob c" wrote:

I copied some bode from a book that takes up about 3 pages that isn't working.

I get the following error message:

"Run-time error €˜1004;
Method €˜Range of object €˜_Worksheet failed"



When I click on debug the following line is highlighted:

"Set rgTopLeft = ws.Range(FOUND_LIST).Offset(1, 0)"

Any suggestions on how I can find out what needs to be changed in order to
make this work?

Regards,

Rob


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
Run-time error €˜1004 Code Numpty Excel Programming 11 September 8th 08 12:41 PM
Error handling error # 1004 Run-time error [email protected] Excel Programming 3 May 20th 08 02:23 PM
Run Time Error 1004: Application or Object Defined Error BEEJAY Excel Programming 4 October 18th 06 04:19 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM


All times are GMT +1. The time now is 05:41 AM.

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"