+ Reply to Thread
Results 1 to 2 of 2

Referring to a worsheet in another workbook

  1. #1
    Roundy
    Guest

    Referring to a worsheet in another workbook

    I am attempting to get this code to work. The issue I am having is that the
    worksheet named Socal Work Order is in another workbook. HOw do I refer to
    it? Is there a way I can do it without using the workbook name, provided
    both workbooks are open? I am using Office 2003 Pro SP2.

    Dim Inrng As Range
    Dim ORng As Range
    Dim inWs As Worksheet
    Dim outWs As Worksheet
    Dim iLastRow As Long

    Set inWs = ActiveSheet
    Set outWs = Worksheets("SoCal Work Order")
    Set ORng = outWs.Cells(outWs.Cells(92, 1).End(xlUp).Row + 1, "A")

    TIA


  2. #2
    Jim Cone
    Guest

    Re: Referring to a worsheet in another workbook

    Sub GetItHereForFree()
    On Error GoTo Err_Handler
    Dim Inrng As Range
    Dim ORng As Range
    Dim inWs As Worksheet
    Dim outWs As Worksheet
    Dim WB As Excel.Workbook

    On Error Resume Next
    For Each WB In Excel.Workbooks
    Set outWs = WB.Worksheets("SoCal Work Order")
    If Err.Number = 0 Then Exit For
    Err.Clear
    Next
    On Error GoTo Err_Handler

    If Not outWs Is Nothing Then
    Set ORng = outWs.Cells(92, 1).End(xlUp)(2, 1)
    MsgBox ORng.Address(external:=True)
    Else
    MsgBox "Oops"
    Exit Sub
    End If

    Set inWs = ActiveSheet
    'something else
    Exit Sub

    Err_Handler:
    'handle error
    End Sub
    ------------

    Jim Cone
    San Francisco, USA
    http://www.realezsites.com/bus/primitivesoftware


    "Roundy"
    <[email protected]>
    wrote in message
    I am attempting to get this code to work. The issue I am having is that the
    worksheet named Socal Work Order is in another workbook. HOw do I refer to
    it? Is there a way I can do it without using the workbook name, provided
    both workbooks are open? I am using Office 2003 Pro SP2.

    Dim Inrng As Range
    Dim ORng As Range
    Dim inWs As Worksheet
    Dim outWs As Worksheet
    Dim iLastRow As Long

    Set inWs = ActiveSheet
    Set outWs = Worksheets("SoCal Work Order")
    Set ORng = outWs.Cells(outWs.Cells(92, 1).End(xlUp).Row + 1, "A")

    TIA


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1