View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
jfcby[_2_] jfcby[_2_] is offline
external usenet poster
 
Posts: 121
Default Reference 2 separate workbooks!

Version: Excel 2000 & 2003
* using only one instance

I'm stuck and have no other ideas, I've search the newsgroup and
researched my macros and I can't find my problem with the following
macro.

Workbooks("Equip_List_FF.xls").Worksheets: has about 306 worksheets
visible and hidden. I need to get data from each worksheet and copy it
to Workbooks("FF_Zone5_Bldgs.xls").Worksheets("WATER TREATMENT -
(ALPH)").

But, when I run this macro it gives me the error "Object required" and
I can't figure out why. Could someone point me in the right direction
to fix this error, than you for your help.

Sub WorkSheetsBldgNumberNameCellB()
'Worksheets Building Name & Number in cell
'------
Dim wbkA As Workbook, wbkB As Workbook
Dim wksA As Worksheet, wksB As Worksheet
Application.ScreenUpdating = False
Set wbkA = Workbooks("Equip_List_FF.xls")
Set wbkB = Workbooks("FF_Zone5_Bldgs.xls")
Set wksB = wbkB.Worksheets("WATER TREATMENT - (ALPH)")
'------
For Each wksA In wbkA.Worksheets
If wksA.Visible = xlSheetVisible Then
'------
wksB.Worksheets("WATER TREATMENT -
(ALPH)").Range("B65535").End(xlUp).Offset(1, 0).Address = _
Right(wksA.Range("C2"), 4).Value '1 below last row of data skip
blanks
'------
wksB.Range("B65535").End(xlUp).Offset(, 1) =
Left(wksA.Range("C1").Value, _
Len(wksA.Range("C1").Value) - 16)
End If
Next
Application.ScreenUpdating = True
End Sub

Thank you for your help,
jfcby