Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VB6 and Excel - 1004 error

Thanks Ron and Samura. That worked.

"Rob Bovey" wrote in message
...
Change the line:

Set myRng = myWs.Range(myWs.Cells(1, 2)) '<== Error 1004

to:

Set myRng = myWs.Cells(1, 2)

The first line of code is feeding a Range object to the Range property of

a
Worksheet. This is not allowed.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"news.easynews.com" wrote in message
...
Why would the following code give the error: 1004: Method 'Range' of

object
'_Worksheet' failed


Dim myExcel As Excel.Application
Dim myWb As Excel.Workbook
Dim myWs As Excel.Worksheet
Dim myRng As Excel.Range

Set myExcel = New Excel.Application
Set myWb = myExcel.Workbooks.Open("d:\test.csv")
Set myWs = myWb.Sheets(1)
Set myRng = myWs.Range(myWs.Cells(1, 2)) '<== Error 1004

MsgBox myRng.Address


If I change the line giving the error to

Set myRng = myWs.Range("B1")

then it's ok. Any suggestions?


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
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Error 1004 in Excel 97... Mike[_81_] Excel Programming 3 May 2nd 04 03:37 AM
Error 1004 in Excel 2000 YaakovSinai Excel Programming 0 April 18th 04 03:46 PM
EXCEL VBA - Run-time Error 1004 sakieboy Excel Programming 5 January 30th 04 03:47 PM
EXCEL VBA - Run-time Error 1004 sakieboy[_3_] Excel Programming 0 January 29th 04 02:27 PM


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