Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Object Required Error, Excel 2000 & 2003

Hello,

Why am I getting the Object required Error in the following macro
code?:

Sub HideWorkSheetsC()

Dim wbA As Workbook
Dim wbB As Workbook
Dim wsA As Worksheet
Dim wsB As Worksheet

Set wbA = Workbooks("Equip_List_FF.xls")
Set wbB = Workbooks("FF_ZoneBuildingEquipList.xls")
For Each wsA In wbA.Sheets
For Each cell In wbB.Worksheets("ZONE 5 - BLDG
LIST").Range("D4:D68")
If Right(wsA.Range("C2"), 4).Value = cell Then GoTo nws 'Object
Required Error
If Right(wsA.Range("C2"), 4).Value < cell Then GoTo hws 'Object
Required Error
Next cell
hws:
ws.Visible = xlSheetHidden 'xlSheetVisible
nws:
Next wsA

End Sub

Thenk you for your help,
jfcby

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Object Required Error, Excel 2000 & 2003

Couple of errors:

1) Right(wsA.Range("C2"), 4).Value doesn't make sense - Right() takes
the .Value of wsa.Range("C2") and returns a 4-character string. The
string doesn't have a .Value property.

2) You're obviously not using Option Explicit at the top of the module
or you'd find that

hws:
ws.Visible = xlSheetHidden

refers to an undefined variable, ws.

I"m not positive, but perhaps this will do what you're looking for:

Public Sub HideWorkSheetsC()
Dim wsA As Worksheet
Dim rTest As Range
Dim sCheck As String

Set rTest = Workbooks("FF_ZoneBuildingEquipList.xls").Workshee ts( _
"ZONE 5 - BLDGLIST").Range("D4:D68")
For Each wsA In Workbooks("Equip_List_FF.xls").Worksheets
sCheck = Right(wsA.Range("C2").Text, 4)
If Application.CountIf(rTest, sCheck) 0 Then _
wsA.Visible = xlSheetHidden
Next wsA
End Sub



In article . com,
jfcby wrote:

Hello,

Why am I getting the Object required Error in the following macro
code?:

Sub HideWorkSheetsC()

Dim wbA As Workbook
Dim wbB As Workbook
Dim wsA As Worksheet
Dim wsB As Worksheet

Set wbA = Workbooks("Equip_List_FF.xls")
Set wbB = Workbooks("FF_ZoneBuildingEquipList.xls")
For Each wsA In wbA.Sheets
For Each cell In wbB.Worksheets("ZONE 5 - BLDG
LIST").Range("D4:D68")
If Right(wsA.Range("C2"), 4).Value = cell Then GoTo nws 'Object
Required Error
If Right(wsA.Range("C2"), 4).Value < cell Then GoTo hws 'Object
Required Error
Next cell
hws:
ws.Visible = xlSheetHidden 'xlSheetVisible
nws:
Next wsA

End Sub

Thenk you for your help,
jfcby

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Object Required Error, Excel 2000 & 2003

Hello JE McGimpsey,

Thank you for your macro code (works great!), it help me figure out
how to get the following macro code to work. But, I did not know how
to modify your code (still learning how to wright macro's) so I
continued to change the following code:

Sub HideWorkSheetsC()

Dim wbA As Workbook
Dim wsA As Worksheet
Dim ceTa As String
Dim ceTb As String

Set wbA = Workbooks("Equip_List_FF.xls")
For Each wsA In wbA.Sheets
For Each cell In
Workbooks("FF_ZoneBuildingEquipList.xls").Workshee ts( _
"ZONE 5 - BLDG LIST").Range("D4:D68")
ceTa = Right(Range("A2").Text, 4)
ceTb = Right(Range("C2").Text, 4)
If ceTa = cell Or ceTb = cell Then GoTo nws
Next cell
wsA.Visible = xlSheetHidden
nws:
Next wsA

End Sub

Thank you for your help and macro,
jfcby

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Object Required Error, Excel 2000 & 2003

Hello,

Corrections made to the above macro code:


Sub HideWorkSheetsC()


Dim wbA As Workbook
Dim wsA As Worksheet
Dim ceTa As String
Dim ceTb As String


Set wbA = Workbooks("Equip_List_FF.xls")
For Each wsA In wbA.Sheets
For Each cell In
Workbooks("FF_ZoneBuildingEquipList.xls").Workshee ts( _
"ZONE 5 - BLDG LIST").Range("D4:D68")
ceTa = Right(wsA.Range("A2").Text, 4)
ceTb = Right(wsA.Range("C2").Text, 4)
If ceTa = cell Or ceTb = cell Then GoTo nws
Next cell
wsA.Visible = xlSheetHidden 'xlSheetVisible
nws:
Next wsA


End Sub


jfcby



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
Object works in Excel 2000 but not in 2003 IBTrini Excel Programming 2 March 28th 07 03:01 AM
Excel VBA Classes Error: 424 Object Required Sooty Excel Programming 2 November 20th 06 01:21 PM
Excel 2007 Beta 2 - Macro Run-time error '424' Object required jcm21 Excel Programming 0 June 16th 06 07:17 PM
Calender Object problem in Excel 2000 and 2003 Suketu Excel Discussion (Misc queries) 0 April 20th 06 08:29 PM
"Object Required" Error in Excel 2000 but Not in Excel 97 (!?) James Pannozzi Excel Programming 0 May 17th 04 11:39 PM


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