Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Runtime error 424 object required on Set Statement

Good afternoon, Can someone please explain why I'm getting a runtime
errror on the following code:

' I declared the workbook and worksheet in the beginning of the
program:
Dim volume_WB as Workbook
Dim volume_sheet as Worksheet

' I open the workbook
Set volume_WB = Workbooks.Open("DASD.volumes.test.xls", UpdateLinks:=0)

' I call a routine to pass the workbook

Call dasdType(site, frowV2X, frowSHK, volume_WB, volume_sheet)

' site = a 2-character desgination. it will be either HQ or NE
' The program bombs on the first line:

Set volume_sheet = volume_WB.Sheets(site & "-V2X")

What am I doing wrong?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Runtime error 424 object required on Set Statement

Without seeing more code it is a little tough but here is something to try...

sub Whatever()
Dim volume_WB as Workbook
Dim volume_sheet as Worksheet

On error goto OpenError
Workbooks.Open("DASD.volumes.test.xls", UpdateLinks:=0)
on error goto 0
Set volume_WB = activeworkbook
if sheetexists(site & "-V2X", volume_WB) then
Set volume_sheet = volume_WB.Sheets(site & "-V2X")
Call dasdType(site, frowV2X, frowSHK, volume_WB, volume_sheet)
else
msgbox "Sorry no such sheet"
end if
exit sub
OpenError:
msgbox "Sorry Can't open the file"
end sub

Public Function SheetExists(SName As String, _
Optional ByVal WB As Workbook) As Boolean
'Chip Pearson
On Error Resume Next
If WB Is Nothing Then Set WB = ThisWorkbook
SheetExists = CBool(Len(WB.Sheets(SName).Name))
End Function

--
HTH...

Jim Thomlinson


"looloo" wrote:

Good afternoon, Can someone please explain why I'm getting a runtime
errror on the following code:

' I declared the workbook and worksheet in the beginning of the
program:
Dim volume_WB as Workbook
Dim volume_sheet as Worksheet

' I open the workbook
Set volume_WB = Workbooks.Open("DASD.volumes.test.xls", UpdateLinks:=0)

' I call a routine to pass the workbook

Call dasdType(site, frowV2X, frowSHK, volume_WB, volume_sheet)

' site = a 2-character desgination. it will be either HQ or NE
' The program bombs on the first line:

Set volume_sheet = volume_WB.Sheets(site & "-V2X")

What am I doing wrong?


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 '424': Object Required loren.pottinger Excel Discussion (Misc queries) 1 August 28th 06 09:56 PM
"Microsoft Visual Basic runtime error '424' object required". SharonG. Excel Worksheet Functions 0 July 5th 06 01:36 AM
Runtime error 424 - Object required periro16[_8_] Excel Programming 1 September 21st 05 05:36 PM
runtime error ....object required mlm Excel Programming 3 February 18th 04 06:09 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


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