Reference External Workbook Code

seenfresh

Well-known Member
Joined
Jul 12, 2006
Messages
1,141
I am wondering what would be the best way to reference a closed Excel Workbook using VB within Excel?

I have a workbook location:
Code:
\\Nymas01\finance\Budget\Budget 2008\Exports

And worksheet named:
Code:
PLATFORM

I would like to reference this closed workbook using say: this line

Code:
"MYCLOSEDWORKBOOK".Cells(1,"A").Value

Any advice would be great!

Thanks in advance,
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
reply

Thank you PennySaver!

I would rather call the workbook and work accross two workbooks... I'm not quite fluent enough in VB to use Ozgrid's suggestions quite yet!

Working accross two Workbooks would help my understanding of using multiple objects.. guess it would be a good start!

My problem lies in the following code this line gets highlighted as an error with no error message!

Code:
Set WbBook2 = Workbooks("License Fees_2008.xls").Worksheets("FRX not in PLATFORM")

Here is my code and I'm just trying to set the references to each seperate workbook... but having difficulty

Code:
Sub FRXtoPLATFORM()
ApplicationScreenUpdating = False


Dim wbBook1 As Worksheet
Dim WbBook2 As Worksheet


Workbooks.Open ("\\Nymas01\finance\Budget\Budget 2008\Exports\PLATFORM.xls")


Set wbBook1 = Workbooks("PLATFORM.xls").Worksheets("PLATFORM")
Set WbBook2 = Workbooks("License Fees_2008.xls").Worksheets("FRX not in PLATFORM")
PLATFORM = wbBook1
FRX = WB2



x = PLATFORM.Cells(Rows.Count, "C").End(xlUp).Row
For iRow = 1 To x
If FRX.Cells(iRow, "C").Value = "-" Then

GROUP = Cells(iRow + 1, "B").Value
    
    
    With PLATFORM
    
        c = WorksheetFunction.CountIf(.Range("A:A"), GROUP)
    
      
        ' TRYING TO FIND the Text of datae represented earlier!
        If c = 0 Then
        
            ' IF WE CAN'T FIND IT, then insert iGroup..
            
            theRow = .Cells(Rows.Count, "A").End(xlUp).Row + 1
            ' This finds a row starting from top that is empty to put the new values in!!!
            .Cells(theRow, 1).Value = GROUP
            
        End If
    End With
            
    
End If

Next iRow

End Sub

wbBook2 is the workbook that holds the procedure...

Can you spot any errros at all? Any help would be greatly appreciated!

Thanks in advance,
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,269
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top