Results 1 to 3 of 3

ThisSheet or ThisWorksheet

This is a discussion on ThisSheet or ThisWorksheet within the Excel Questions forums, part of the Question Forums category; Hi, how there is: ActiveWorkbook AND ThisWorkbook, is there ThisSheet or ThisWorksheet (from ActiveSheet)? How can I refer a "Private ...

  1. #1
    Board Regular
    Join Date
    Oct 2002
    Location
    Bergamo-Italy
    Posts
    585

    Default ThisSheet or ThisWorksheet

    Hi,
    how there is: ActiveWorkbook AND ThisWorkbook, is there ThisSheet or ThisWorksheet (from ActiveSheet)?

    How can I refer a "Private Sub Worksheet_Change(ByVal Target As Range)"
    to ThisSheet or ThisWorksheet?

    Tia.
    Maurizio

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339

    Default Re: ThisSheet or ThisWorksheet

    Quote Originally Posted by maurizio.rota
    Hi,
    how there is: ActiveWorkbook AND ThisWorkbook, is there ThisSheet or ThisWorksheet (from ActiveSheet)?

    How can I refer a "Private Sub Worksheet_Change(ByVal Target As Range)"
    to ThisSheet or ThisWorksheet?

    Tia.
    The event refers to a change on the active worksheet anyway, so there's no need to qualify references to ranges etc. If you want, you can use the Me keyword within a worksheet's module to refer to the worksheet.

  3. #3
    Board Regular
    Join Date
    Oct 2002
    Location
    Bergamo-Italy
    Posts
    585

    Default Re: ThisSheet or ThisWorksheet

    Quote Originally Posted by Mudface
    Quote Originally Posted by maurizio.rota
    Hi,
    how there is: ActiveWorkbook AND ThisWorkbook, is there ThisSheet or ThisWorksheet (from ActiveSheet)?

    How can I refer a "Private Sub Worksheet_Change(ByVal Target As Range)"
    to ThisSheet or ThisWorksheet?

    Tia.
    The event refers to a change on the active worksheet anyway, so there's no need to qualify references to ranges etc. If you want, you can use the Me keyword within a worksheet's module to refer to the worksheet.
    Hi Mudface,
    this all my code:

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Dat7 As Byte, DatB_C As Byte, DatB As Byte, DatC As Byte, DifOK As Byte
    Dim ImpOk As Long
        Dat7 = Application.WorksheetFunction.CountA(ActiveSheet.Range("B5:B13"))
        ImpOk = Abs(ActiveSheet.Range("B2"))
        DatB_C = Application.WorksheetFunction.CountA(ActiveSheet.Range("B15:C24"))
        DatB = Application.WorksheetFunction.CountA(ActiveSheet.Range("B15:B24"))
        DatC = Application.WorksheetFunction.CountA(ActiveSheet.Range("C15:C24"))
        If Dat7 >= 7 And DatB_C >= 2 And DatB = DatC And ImpOk = 0 Then Cells(65536, 2).End(xlUp).Offset(1, 0).Select
    End Sub
    and if I active an other sheet with click-mouse while a cell of ActiveSheet is active (is working: I don't push enter key) I get error.
    Maurizio

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com