Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    milton keynes, Buckinghamshire
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Range specification (2003)

    The following code works:

    Range("TotalGLCC273") = "='" & CurDir & "273 Accounts P" & strPeriod & ".xls'!CostsByGL"

    However I would like to amend it to something more like the following:

    Thisworkbook.Range("TotalGLCC273") = "='" & CurDir & "273 Accounts P" & strPeriod & ".xls'!CostsByGL"

    The above causes an error.

    Can somebody please advise what I can use instead of "ThisWorkBook"

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Range specification (2003)

    ThisWorkbook represents the Excel workbook as a whole (the .xls file). A Range is a property of an individual worksheet within the workbook. You can use

    ActiveSheet.Range("TotalGLCC273") = "..."

    to specify that the range is on the currently active sheet, or

    Worksheets("MySheet").Range("TotalGLCC273") = "..."

    to specify that the range is on the worksheet named MySheet in the currently active workbook, or

    Workbooks("MyWorkbook.xls").Worksheets("MySheet"). Range("TotalGLCC273") = "..."

    to specify that the range is on the worksheet MySheet in the workbook MyWorkbook.xls.

  3. #3
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    milton keynes, Buckinghamshire
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Range specification (2003)

    Thanks

    That has worked

Posting Permissions

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