Consulting

Results 1 to 4 of 4

Thread: Referencing Other Open Workbooks.

  1. #1

    Referencing Other Open Workbooks.

    Hi All,

    cant seem to get the code below to work. When the two sheets are in the same workbook the code works fine but once i try to reference it from different workbooks I get a Run-time error '13': Type mismatch code.

    any help - its probably something simple.

    [vba]Sub ResolverClosed_Update_SLA_ResolvedCol()

    Dim R As Range
    Dim Value As Integer
    Dim CEC As Worksheets
    Dim Template As Worksheets
    Set CEC = Application.Workbooks("CEC_Calculations.xls").Worksheets("Resolver_Closed")
    Set Template = Application.Workbooks("CEC Weekly Performance Report -Template.xls").Worksheets("Resolver - Priority (Closed)")
    CEC.Select
    Template.Range("L6").Select
    Do
    Set R = CEC.Range("K4:L2000").Find(ActiveCell.Offset(0, -10))
    If Not R Is Nothing Then ActiveCell = R.Offset(0, 1).Value
    ActiveCell.Offset(1, 0).Select
    Loop Until IsEmpty(ActiveCell.Offset(0, -10))
    End Sub[/vba]

    thanks.

    paddy.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,445
    Location
    [vba]

    Sub ResolverClosed_Update_SLA_ResolvedCol()

    Dim R As Range
    Dim Value As Integer
    Dim CEC As Worksheet
    Dim Template As Worksheet
    Set CEC = Application.Workbooks("CEC_Calculations.xls").Worksheets("Resolver_Closed")
    Set Template = Application.Workbooks("CEC Weekly Performance Report -Template.xls").Worksheets("Resolver - Priority (Closed)")
    CEC.Select
    Template.Range("L6").Select
    Do
    Set R = CEC.Range("K4:L2000").Find(ActiveCell.Offset(0, -10))
    If Not R Is Nothing Then ActiveCell = R.Offset(0, 1).Value
    ActiveCell.Offset(1, 0).Select
    Loop Until IsEmpty(ActiveCell.Offset(0, -10))
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Hi this works until the line:

    [VBA]Template.Range("L6").Select[/VBA]

    I then get the error message:

    Run-time error '1004':
    Select method of Range class failed

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,445
    Location
    Break it down

    [vba]

    Template.Activate
    Range("L6").Select
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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